How to update data using transform map

Anna_Servicenow
Tera Guru

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?

13 REPLIES 13

@Anna_Servicenow 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Vishal Birajdar
Giga Sage

@Anna_Servicenow 

 

You can use onAfter Transform script

 

VishalBirajdar7_0-1694701498914.png

 

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();
        }
}

VishalBirajdar7_1-1694701949657.png

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

This partly worked!! 

It is updating when record is found, But while inserting it is getting inserted in cmdb_ci not cmdb_ci_netgear

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.