Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Copy tags from one table to another

Utkarsha
Tera Contributor

Hello All,

I am using below query BR to copy tags from one table to another, but currently all records from the target table are getting updated I want only the associated record should have the tag copied from source record which has new tag added.

Please suggest any changes here,

Thank you,

 

After insert BR-label_entry table

if (current.operation() == 'insert'){
 
var controlObjRec = new GlideRecord('sn_compliance_control');
controlObjRec.addEncodedQuery('content='+current.table_key+'^source_listISNOTEMPTY');
controlObjRec.query();
while(controlObjRec.next())
{

var tagRec = new GlideRecord('label_entry');
tagRec.initialize();
tagRec.table='sn_compliance_control';
tagRec.table_key=controlObjRec.sys_id;
tagRec.label=current.label;
tagRec.title=controlObjRec.name;
tagRec.read='yes';
tagRec.insert();

}
var control = new GlideRecord('control_test');
control.addEncodedQuery('content='+current.table_key+'^source_listISNOTEMPTY');
control.query();
while(control.next())
{

var tagPec = new GlideRecord('label_entry');
tagPec.initialize();
tagPec.table='control_test';
tagPec.table_key=control.sys_id;
tagPec.label=current.label;
tagPec.title=control.name;
tagPec.read='yes';
tagPec.insert();

}

 

0 REPLIES 0