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.

Custom action script not updating the records

shalikasurbhi1
Tera Contributor

I have defined the inputs in custom action as -

shalikasurbhi1_0-1713335950904.png

And run script as -

(function execute(inputs, outputs) {
var gr=new GlideRecord('sc_request');
gr.addQuery('sys_id','inputs.request');
gr.query();
if(gr.next())
{
 
gr.short_description = inputs.shortdescription;
gr.update();
}

})(inputs, outputs);
 
And in flow -
shalikasurbhi1_1-1713336583169.png

But it is not updating the sc_request

 

1 ACCEPTED SOLUTION

You code has a small Error and you code must be something like below

(function execute(inputs, outputs) {
var gr=new GlideRecord('sc_request');
gr.addQuery('sys_id',inputs.request);
gr.query();
if(gr.next())
{
 
gr.short_description = inputs.shortdescription;
gr.update();
}

})(inputs, outputs);

 

Please Mark my answer as correct if that helps.....

 

Thanks.

View solution in original post

2 REPLIES 2

Jon23
Mega Sage

Hi @shalikasurbhi1 ,

You have quotes around 'inputs.request' in your run script line: gr.addQuery('sys_id','inputs.request');

The quotes are making it a string value. Remove the quotes to use the variable value.

You code has a small Error and you code must be something like below

(function execute(inputs, outputs) {
var gr=new GlideRecord('sc_request');
gr.addQuery('sys_id',inputs.request);
gr.query();
if(gr.next())
{
 
gr.short_description = inputs.shortdescription;
gr.update();
}

})(inputs, outputs);

 

Please Mark my answer as correct if that helps.....

 

Thanks.