Ignore a field when the value is not a serial number in a transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 06:25 AM
Hi
I have a issue where serial numbers are been overwritten by blank values when running a transform
e.g.
CI has serial number 'abc'
Import Set has nothing in the serial number
Transform runs
CI serial number is blank
What is best way to Skip\Ignore the transform from overwriting the value. However, I still want the other fields to update and not to skip the full row. I don't think its an Empty field as I have the 'Copy empty fields' unticked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 06:41 AM
Hi @Adam Wood ,
Delete the mapping for serial number in the Transform map as shown below to stop overriding the values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 06:48 AM
If you only want to avoid overriding when source is empty , you can
enable source script for field map on transform map and write script as follow:
if (JSUtil.nil(source.serial_number)) {
ignore = true;
}
Refer image
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 08:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 06:51 AM
remove field map for it and use onbefore transform script
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
if(global.JSUtil.notNil(source.u_serial_number)){
target.serial_number = source.u_serial_number;
}
})(source, map, log, target);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
