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.

illegal access to getter method getmessage

vampyre82nd
Giga Expert

This script is on a workflow approval activity, the workflow properties is on the task [task] table, the new fields are on the sysapproval_approver table. when I run the workflow the approval is not created and the error "illegal access to getter method getmessage in class org.mozilla.javascript.rhino exception" comes up. Any help is appreciated. 


// Set the variable 'answer' to a comma-separated list of user ids and/or group ids or an array of user/group ids to add as approvers.
//
// For example:
// answer = [];
// answer.push('id1');
// answer.push('id2');


sysapproval.u_release_short_description = 'HRD_PPSD_PSB_Branch_Chief';

sysapproval.u_approval_release_date = current.sysapproval.work_end;

var gdt = new GlideDateTime(sysapproval.u_approval_release_date);
gdt.addDays(-2); //change this to change the number of days
sysapproval.u_approval_end_date = gdt;

1 REPLY 1

Ashley Snyder1
Giga Guru

Is that your full script?

Let me make sure I am following.  You're using a workflow activity on a task, which table is it?  Is it sc_req_item, or just task?  So current will be whichever table you're running the workflow from, unless it's sysapproval_approver you don't have access to that table yet.  You'll need to GlideRecord to it in order to set values and update the record in your script.

Also I see you're using sysapproval which isn't the full table name.

When using GlideRecord, use Getters and Setters instead of  '=' to avoid Pass By Reference, so something like:

var apprGr = new GlideRecord ('sysapproval_approver');
apprGr.addQuery('whatever you need to get here');
apprGr.query();
if (apprGr.next()) {
apprGr.setValue('u_release_short_description', 'Your short description');
apprGr.update();
}