Code working in background script but not working in run script(workflow).

SD4
Tera Contributor

I am getting approver name 

var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval.number','RITM0395743');
gr.addQuery('state','requested');
gr.query();

if(gr.next())
{
gs.log(gr.approver.name,"Approver");

}

find_real_file.png

but when I am using the same code in the run script, it does not even go into the if statement

find_real_file.png

5 REPLIES 5

Musab Rasheed
Tera Sage
Tera Sage

Hello,

Why are you using this script.? also try to get only sys_id (gr.approver) first and see if that works.?

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Tim Kulhavy
ServiceNow Employee
ServiceNow Employee

Try to make sure that the ritm variable is set correctly, as that is the only real difference between the two statements.

So, try to add a gs.info('DEBUG: ' + ritm) call in line 3 for example. What I think might be the issue here is that you're accessing the ritm number directly using current.number. Try to use current.getValue('number') instead, that might do the trick.

SD4
Tera Contributor

Hi Tim,

I am getting RITM number, 

Or, real oldschool, instead of current.number, use current.number.toString()