Peer approval script getting 'illegal access to mehod getMessage in class org.mozilla.javascriptRhinoException'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 05:29 AM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 05:35 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 10:16 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2018 10:59 AM
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!!