Citizen Service Request - Date field = Dec 31, 1969?

2205
3
Jump to solution
06-19-2013 07:50 AM
Labels (1)
LizDaRos
Regular Contributor
When the service request details view gets populated, one of my date fields says Dec 31, 1969. This field is null and should display N/A not Dec 31, 1969. In the function ServiceRequestDetails(attributes) I can see where the date is declared but I think it needs a if/then statement in case the field is null like in my case. I've tried a few different ways but can't seem to fix this. This is what I came up with; is there something I need to change or is there another place in the utils.js I should put this instead of inside the ServiceRequestDetails(attributes) function?
  
 for (var index in infoWindowData) {       if (!infoWindowData[index].AttributeValue.ActualReInspectionDate == '') {                     infoWindowData[index].AttributeValue.ActualReInspectionDate == showNullValueAs;                   }                     else{                     var date = new js.date();                   }
0 Kudos
1 Solution

Accepted Solutions
MikeTschudi
Frequent Contributor
Hi Liz,

Thank you for reporting this problem. I like to suggest the fix to utils.js shown below, which has been checked into the app's GitHub site. Earlier in the code, nulls have been normalized to empty strings to simplify some other processing, so when we're cycling through the list of fields for the infowindow, we can check if the retrieved date field value is an empty string. The js.date module contains a list of date-conversion routines; I see in hindsight how that name is misleading.

Regards,
Mike

for (var index in infoWindowData) {     var tr = document.createElement("tr");     tbody.appendChild(tr);     switch (infoWindowData[index].DataType) {         case "string":             CreateTableRow(tr, infoWindowData[index].DisplayText, dojo.string.substitute(infoWindowData[index].AttributeValue, attributes));             break;         case "date":             // Extract the desired date field from the list of attributes. If the date is not available, the date field is an empty string             var dateField = dojo.string.substitute(infoWindowData[index].AttributeValue, attributes);             var dateString = showNullValueAs;             if (dateField.length > 0)             {                 var utcMilliseconds = Number(dateField);                 dateString = dojo.date.locale.format(date.utcToLocal(date.utcTimestampFromMs(utcMilliseconds)), {                     datePattern: formatDateAs,                     selector: "date"                 });             }             CreateTableRow(tr, infoWindowData[index].DisplayText, dateString);             break;     } }

View solution in original post

0 Kudos
3 Replies
MikeTschudi
Frequent Contributor
Hi Liz,

Thank you for reporting this problem. I like to suggest the fix to utils.js shown below, which has been checked into the app's GitHub site. Earlier in the code, nulls have been normalized to empty strings to simplify some other processing, so when we're cycling through the list of fields for the infowindow, we can check if the retrieved date field value is an empty string. The js.date module contains a list of date-conversion routines; I see in hindsight how that name is misleading.

Regards,
Mike

for (var index in infoWindowData) {     var tr = document.createElement("tr");     tbody.appendChild(tr);     switch (infoWindowData[index].DataType) {         case "string":             CreateTableRow(tr, infoWindowData[index].DisplayText, dojo.string.substitute(infoWindowData[index].AttributeValue, attributes));             break;         case "date":             // Extract the desired date field from the list of attributes. If the date is not available, the date field is an empty string             var dateField = dojo.string.substitute(infoWindowData[index].AttributeValue, attributes);             var dateString = showNullValueAs;             if (dateField.length > 0)             {                 var utcMilliseconds = Number(dateField);                 dateString = dojo.date.locale.format(date.utcToLocal(date.utcTimestampFromMs(utcMilliseconds)), {                     datePattern: formatDateAs,                     selector: "date"                 });             }             CreateTableRow(tr, infoWindowData[index].DisplayText, dateString);             break;     } }
0 Kudos
LizDaRos
Regular Contributor
Thanks so much Mike, that worked.
0 Kudos
MikeTschudi
Frequent Contributor
Great--thanks for letting me know, Liz

Mike
0 Kudos