09-23-2022 05:50 AM
Hi snaplogic experts,
i have csv file with 56 columns. In order not to map field after field and have 56 rows in mapper, iam using this function (mapping and replacing . with , ).
$.mapValues(x => x.replaceAll('.', ','))
but my problem is: i need to add yesterdays date as first column.
is there any chance to add column to this function or do i need to map all columns and new column will be added as first column?
thank you
Solved! Go to Solution.
09-23-2022 06:22 AM
I’m not sure what the mapValues is doing in your example, but you can use extend() to add to the JSON document. In this case, you would create a new object with your “yesterday” field and extend that with the incoming object. Something like this:
{ "yesterday" : Date.now().minusDays(1).toLocaleDateString() }.extend($)
09-23-2022 06:22 AM
I’m not sure what the mapValues is doing in your example, but you can use extend() to add to the JSON document. In this case, you would create a new object with your “yesterday” field and extend that with the incoming object. Something like this:
{ "yesterday" : Date.now().minusDays(1).toLocaleDateString() }.extend($)