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

@Vamsi43 Yes I think so, try it and tell me, and sorry I saw a mistake in my script, it should look like this, whitout (

(function transformRow(source, target, map, log, isUpdate) {

)

you need to put only 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; // return the value to be put into the target field
    } else {
       target.u_delivery_time  = source.u_delivery_time;
    }

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up. 

best regards 

Hello @MahaAgineo 

Like Below i defined the script and Map fields.

Vamsi43_1-1688550123756.png

 

When I Loaded the below data 

Vamsi43_0-1688550061931.png

It not written the Adobe Acrobat Pro catalog item "Delivery time = 2days ".

 

@Vamsi43 Upadate the script without first and last line

But still not working

Delivery Time on Catalog item is "Duration" type but Variable on Table is "String" field. Do you think we suppose update the script ?

@Vamsi43 Yes you need to convert String to Duration field