Scripting to Map a Field in Transform Map
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2023 08:07 AM
I have 2 fields on table build a transform map to load the data into table.
I want to map the "Service" Field using script.
Can you please help me on this:
If the Service is not empty, map each value of the Excel with the right Service to Target.
I wrote the below script which is not working
answer = (function transformEntry(source) {
if (target.u_delivery_time.nil()) {
target.u_delivery_time = source.u_delivery_time;
}
})(source);Thanks
11 REPLIES 11
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 03:12 AM
Ok: so in the field script use this (I assume you only have days):
var delivery_time = source.u_delivery_time ;//source.u_delivery_time
var day_split = delivery_time.split(' ');
var day = day_split[0];
var result= new GlideDuration(day +' 00:00:00');
return result;and in the run script use this:
if (target.u_delivery_time.nil()) {
var delivery;
var catalogItemGR = new GlidRecord("sc_cat_item");
catalogItemGR.addNullQuery('delivery_time');
catalogItemGR.query();
while (catalogItemGR.next()) {
delivery = source.delivery_time;
}
target.u_delivery_time = delivery;
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 04:43 AM
I got the values like this into the table.