I have documents from salesforce that contain fields with a suffix of '__c' and the dates are formatted in UTC. I want to format the incoming data using the mapValue and the mapKey functions to remove the suffix and make all fields lower case AND format the dates into US/Eastern timezone.
I cant get the code to do all that I want: I have the following configuration:
$.mapKeys((value, key)=>key.endsWith('__c')
? key.replace('__c','').toLowerCase()
:key.toLowerCase())
&&
$.mapValues((value, key) => key.toLowerCase().search("createddate") >=0 && value !=null
? Date.parse(value).toLocaleDateTimeString({"timeZone":"US/Arizona"})
:value)
This logic formats the dates but not the columns If I reverse it the columns are formatted and not the dates. Same thing if I change the && to ||. How can I get both transformations? Please help!
This worked
$.mapKeys((value, key)=>key.endsWith('__c') ? key.replace('__c','').toLowerCase() :key.toLowerCase()).mapValues((value, key) => key.toLowerCase().search("createddate") >=0 && value !=null ? Date.parse(value).toLocaleDateTimeString({"timeZone":"US/Arizona"}) :value)