Illegal access error in workflow

oliver_shields
Mega Contributor

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.

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

harishdasari
Tera Guru

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.

 

 

oliver_shields
Mega Contributor

@Ankur Bawiskar @harishdasari 

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

harishdasari
Tera Guru

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()) ;