Illegal access to getter method getMessage in class org.mozilla.javascript.RhinoException

Puru2
Tera Contributor

Dear All,

One of the custom script in Workflow is throwing the error in Workflow Context as *Illegal access to getter method getMessage in class org.mozilla.javascript.RhinoException*.

The objective of this Workflow activity is to push Group-Approvals.

Following is the code snippet which shows the execution path -->

 

Group-Approval activity : 


if(current.variables.appl){
var arr=[]; 
var rec_arr=[]; 

arr.push(current.variables.appl);

rec_arr=new SCUtils(current).getApplicationApprovals(arr);   //Script Include to call the required group

for(var i=0;i<rec_arr.length;i++){
answer.push(rec_arr[i].toString());
}

 

Script Include

getApplicationApprovals: function (application) {

var arr = [];
var groups = [];
var app_nv = [];

for(var j=0;j<application.length;j++){
app_nv.push(application[j]);
}

for(var i=0;i<app_nv.length;i++){
var record = new GlideRecord('cmdb_ci_appl');
record.addQuery('sys_id',app_nv[i].toString());
record.query();

if(record.next()){

groups.push(record.approval_group.toString());
}
}
return groups;
},

 

 

Please let me know any suitable modification , if any.

 

Best Regards,

Puru

7 REPLIES 7

benlittle
Tera Expert

I found it happened to me when I tried to .push to an array I had not declared. For example:

 

answer.push(sys_id);

 

gives the error if you have not declared answer as an array earlier in the code. This is a working example:

 

var answer = [];

answer.push(sys_id);

 

 

Helped me in one go!!!

Darrell Flora
Tera Contributor

I know this is old ... but in my case I had a true/false field named "default" in a scoped app.  I got this exact error when checking for the condition "gr.default" in an IF statement.  Seems the "gr.default" is a protected column as it shows up in blue, which I did not notice at first.