Code working in background script but not working in run script(workflow).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-16-2022 02:47 AM
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");
}
but when I am using the same code in the run script, it does not even go into the if statement
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-16-2022 03:00 AM
Hello,
Why are you using this script.? also try to get only sys_id (gr.approver) first and see if that works.?
Regards
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-16-2022 03:00 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-16-2022 03:02 AM
Hi Tim,
I am getting RITM number,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-16-2022 03:03 AM
Or, real oldschool, instead of current.number, use current.number.toString()