How do I know that whether record is inserted or updated using transform map script

SD40
Tera Contributor

How do I know that whether record is inserted or updated using transform map script 

1 ACCEPTED SOLUTION

DrewW
Mega Sage
Mega Sage

So if you use an onBefore script there is an "action" variable that will tell you if its going to update or insert a new record.

https://docs.servicenow.com/bundle/sandiego-platform-administration/page/script/server-scripting/reference/r_MapWithTransformationEventScripts.html

View solution in original post

8 REPLIES 8

palanikumar
Giga Sage

You can't figure if it is inserted or updated using transform map script. You can add a log and check the status.

If you want to know whether record is created or updated using the transform map, you can go to System Import Sets > Advanced > Import Sets. Open the import set executed. You will see the data in Import Set Rows related list

Thank you,

Palani

Thank you,
Palani

SD40
Tera Contributor

cant I use action=='update'/action=='insert' in onAfter Script OR isUpdate==true in run script??

SumanthDosapati
Mega Sage
Mega Sage

Hi,

You can use getRowCount() function to get the number of records in the table before and after insert so you can know if record is inserted or not.

Example

var now_GR = new GlideRecord('incident');
now_GR.addQuery('active','true'); now_GR.query(); gs.info("Records in incident table: " + now_GR.getRowCount()); //this will print number of records with above applied filters

 

Regards,

Sumanth

DrewW
Mega Sage
Mega Sage

So if you use an onBefore script there is an "action" variable that will tell you if its going to update or insert a new record.

https://docs.servicenow.com/bundle/sandiego-platform-administration/page/script/server-scripting/reference/r_MapWithTransformationEventScripts.html