How to update data using transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 02:39 AM
I have a requirement where I need to update the network type of different CI classes.
I have a transform map running on cmdb_ci table but I dont find network type in cmdb_ci table but I see it in cmdb_ci_netgear.
How to I use the transform map and update the same?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 07:41 AM
the onBefore transform script I shared should work fine.
please keep your coalesce etc as same; just add this script
please share the status after doing the above changes.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 07:32 AM
You can use onAfter Transform script
onAfter script :
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// will get the sys_id of just created target record. assuming you are mapping "class"
var sysId = target.getValue('sys_id');
var grApp = new GlideRecord('cmdb_ci_netgear');
grApp.addQuery('sys_id', sysId);
grApp.query();
if (grApp.next()) {
grApp. < field_name > = source. < source_fieldName > ;
grApp.update();
}
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:22 AM
This partly worked!!
It is updating when record is found, But while inserting it is getting inserted in cmdb_ci not cmdb_ci_netgear

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 02:28 AM
Hi @Anna_Servicenow,
Create a onBefore script:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (action == 'insert'){
target.sys_class_name = 'cmdb_ci_netgear';
}
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.