Scripting to Map a Field in Transform Map

Vamsi43
Tera Contributor

I have 2 fields on table build a transform map to load the data into table.

 

Vamsi43_0-1688310018939.png

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);

Vamsi43_1-1688310393427.png

Thanks

 

11 REPLIES 11

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;

I got the values like this into the table.

 

Vamsi43_0-1688557338174.png