Hello, I need to process input data in a NetSuite Import Step before mapping.
I need to extract the month, year values from the date field of the input data. The input date is in unix timestamp format. Does anyone knows what datetime formatting can be used inside the preMap script (or any kind of hook per say)?
@sujitdesai you can use the dayjs library. See doc example below. You most likely could use handlebar expressions as well just within the mapping instead of having to use a script.
Handlebar example:
https://docs.celigo.com/hc/en-us/articles/360039326071-Handlebars-helper-reference#dateFormat
{{dateFormat "MM" created "X" "America/Chicago"}}
{{dateFormat "DD" created "X" "America/Chicago"}}
{{dateFormat "YYYY" created "X" "America/Chicago"}}
{{dateFormat "YYYY-MM-DD" created "X" "America/Chicago"}}
Script example:
import dayjs from 'dayjs';
function test (options) {
for (let d of options.data) {
d.created_date = dayjs.unix(d.created).format('YYYY-MM-DD');
d.created_year = dayjs.unix(d.created).format('YYYY');
d.created_month = dayjs.unix(d.created).format('MM');
d.created_day = dayjs.unix(d.created).format('DD');
}
return options;
}