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.

Need to update 'CI' and 'Service' via background script for a Closed record. I see the record is getting updated but CI and Service is not showing on the record.

sbeginner
Kilo Guru

Need to update 'CI' and 'Service' via background script for a Closed record. I see the record is getting updated but CI and Service are not showing on the record.

I am using the below script:

var grchange = new GlideRecord('incident');
grchange.addQuery('sys_id','96380daf8760511066d4766acebb3516');
grchange.query();
if(grchange.next()){
grchange.cmdb_ci = 'ABC';

grchange.business_service = 'XYZ';
grchange.setWorkflow(false);
grchange.update();

}

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Hi cmdb_ci  and  business_service  are reference fields you need to set using displayvalue since your passign the name.

try the below

var grchange = new GlideRecord('incident');
grchange.addQuery('sys_id','3c7808621bc5511009ad9758b04bcbe3');
grchange.query();
if(grchange.next()){
grchange.setDisplayValue('business_service','SAP Enterprise Services'); 
grchange.setDisplayValue('cmdb_ci','*BOW-IBM');
grchange.setWorkflow(false);
grchange.update();

}

Regards
Harish

View solution in original post

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

Hi cmdb_ci  and  business_service  are reference fields you need to set using displayvalue since your passign the name.

try the below

var grchange = new GlideRecord('incident');
grchange.addQuery('sys_id','3c7808621bc5511009ad9758b04bcbe3');
grchange.query();
if(grchange.next()){
grchange.setDisplayValue('business_service','SAP Enterprise Services'); 
grchange.setDisplayValue('cmdb_ci','*BOW-IBM');
grchange.setWorkflow(false);
grchange.update();

}

Regards
Harish

sbeginner
Kilo Guru

Thanks a Harish it work.