Illegal access error in workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 06:45 AM
Ive written the below code in an 'Approval - User' activity on a workflow. Its purpose is to pull users from a glide list field on the software table (the field itself is on the cmdb_ci table) and add them as approvers on a REQ task. However im getting this error: Illegal access to getter method getMessage in class org.mozilla.javascript.RhinoException
Please dont mock my code too much, im not a coder and most of my codes are frankensteins monsters from other bits of code people have written:
var r = new GlideRecord('sc_req_item');
r.addQuery('request',current.sys_id);
r.query();
if(r.next())
{
var Approvers = (r.Variables.please_select_the_software_you_would_like.u_sw_add_approvers) ;
}
{
answer.push = Approvers;
}
Thanks for any assistance.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 07:08 AM
Hi Oliver,
Is this script inside the approval activity in the workflow?
update code as below; Is the variable a slush bucket holding multiple values?
var Approvers;
var r = new GlideRecord('sc_req_item');
r.addQuery('request',current.sys_id);
r.query();
if(r.next())
{
Approvers = r.variables.please_select_the_software_you_would_like.u_sw_add_approvers;
}
Approvers = Approvers.toString().split(',');
answer.push = Approvers;
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 07:10 AM
Hi Oliver,
you have given the Variable where V is a uppercase, change to lowercase in the below line
From
var Approvers = (r.Variables.please_select_the_software_you_would_like.u_sw_add_approvers) ;
TO
var Approvers = (r.variables.please_select_the_software_you_would_like.u_sw_add_approvers) ;
And after this line put the print to check what are the values it is printing.
gs.print('Here are the Approvers' + Approvers)
Hope this information is Helpful to fix the issue.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 07:56 AM
Thank you both. Ive tried both of your solutions but unfortunately im still getting the same error when the workflow gets to that point. Ive also tried adding .sys_id to the variable lookup on line 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2020 08:11 AM
Can you please check giving getDisplayValue at the end of the code.
var Approvers = (r.Variables.please_select_the_software_you_would_like.u_sw_add_approvers.getDisplayValue()) ;