We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Help transform map

Snowman15
Giga Guru

Hi everyone,

I'm working on a Transform script in ServiceNow and need help with a specific use case. During the transformation process, I want to redirect certain records to a different table ( different from the target), and prevent them from being inserted into the original target table. This is correctly working with script I created, however when the records are created to the NON target table, field mapped are returning blank. Is there a way to map those fields to the NON target table? Thanks

This is the script: 

 

(function runTransformScript(source, map, log, target /*undefined onStart*/) {

 

    var softType = (source.u_softwtype || '').toString().trim().toLowerCase();

 

    if (softType === 'free') {

        // Create a new record 

        var softRecord = new GlideRecord('x_sw_software_new_list');

        softRecord.initialize();

        softRecord.price = source.u_price;

        softRecord.name= source.u_name;

        softRecord.insert();

 

       

        ignore = true;

    }

 

})(source, map, log, target);

3 REPLIES 3

brianlan25
Kilo Patron

Try doing the following instead for the price and name fields.

softRecord.setValue('price', source.u_price);

softRecord.setVlaue('name', source.u_name);

 

This is how to shows inserts in DOC to do a record insert.

Hi @brianlan25 unfortunately it didnt work at all, didnt even create the records anymore. I tried softRecord.setValue('price', source.u_price); and also softRecord.setValue('price', 'source.u_price'); but no luck

Ok let put in after the initialize gs.log("Price: " + source.u_price); and gs.log("Name: " + source.u_name); Also can your verify that the field type for u_price and u_name match the field type on your destination table for price and name.