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 catalog variables to RITM and REQ forms.

Priyanka Pawar1
Mega Expert

Hello All,

 

I am trying to copy a location catalog variable on Request item and request form.

I have written the below code.

I have a run activity on request item workflow which is trying to set the location variable on scratchpad.

 

Run script activity on workflow.

 find_real_file.png

Then I am running a after business rule on request item table to set the location variable value on request item form and request form’s filed called location.

 

 find_real_file.png

But this script is not working, I have tried multiple thing but unable to do so.

Can anyone help me over here?

 

Regards,

Priyanka

1 ACCEPTED SOLUTION

dvp
Mega Sage

If I understand it correct you would like to update location field on RITM and Request using the location variable

Try the below script in Run script

//Update location field on RITM
current.location = current.variables.location;

//Update location field on Request
var gr = new GlideRecord("sc_request");
gr.addQuery("sys_id", current.request);
gr.query();
if (gr.next()) {
	gr.location = current.variables.location;
	gr.update();
}

View solution in original post

5 REPLIES 5

Hi DVP,

 

thank you, just making one correction in your script.

 

as  location is a reference field, so it is working with setDisplayValye function. 

 

Below script I have used.

 


//Update location field on RITM
current.setDisplayValue('location', current.variables.location);


//Update location field on Request
var gr = new GlideRecord("sc_request");
gr.addQuery("sys_id", current.request);
gr.query();
if (gr.next()) {
gr.setDisplayValue('location', current.variables.location);
gr.update();
}