Peer approval script getting 'illegal access to mehod getMessage in class org.mozilla.javascriptRhinoException'

renielowery
Tera Contributor

I have been trying all day to write an "peer" approval script to create approval records for all users, except if user is author.   I have tried this many ways and it was giving no result and going to the next level approval.   I then tried a version of a script from   https://community.servicenow.com/thread/276062 and am getting "Illegal access to method getMessage in class org.mozilla.javascriptRhinoException.   By version, I mean I just want to check one group, and if the group member is the same as the author, I don't want to add them as an approval user.

I am very new to Service Now and javascript!!

This is the code I have:

var peers = [];

      var users = new GlideRecord('sys_user_grmember');
      users.addQuery('group','4feb8c00db6bd200d1d6f1fcbf9619e1');
      user.query();
      gs.log("no of user is"+users.getRowCount());
while(gr.next()){
      if(users.user != current.author)
      peers.push(users.user+"");
}
answer=peers;

https://community.servicenow.com/thread/276062

3 REPLIES 3

Stijn Verhulst3
Kilo Guru

Hi Renie,



might be there's another Business Rule running on the same record, trying to apply the getMessage() function of the GlideSystem API while not being called correctly.



I suggest you search through the scripts of the Business Rules on the table where getMessage is being called. Normaly should be declared as "gs.getMessage(...)'.



Just a quick thought.



Kind regards,



Stijn


Susan Britt
Mega Sage
Mega Sage

Hey Renie,



If you copied the script, you have typos in your code:


1)   The query line should be users.query (with "s" at end).  


2)   The while next should be "while(users.next)"..., not gr.next


Thank you sooooooooo much..



The result of trying many different ways of doing the same thing and being new to JavaScript, but with help like that,   I hope to continue my learning to pass it forward soon!!