Help transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 09:35 AM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 10:18 AM - edited 06-03-2025 10:23 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 12:02 PM - edited 06-03-2025 12:02 PM
Hi @Brian Lancaster 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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2025 12:58 PM
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.