Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 02:57 AM
Hi,
I was testing this code in Bg Script and it was not executing getting the error ,
com.glide.script.RhinoEcmaError: "getRoles" is not defined.
Basically trying to pass user defined values to a function and check whether that record is present in the table or not.
var role_new = 'it_executive';
var user_new = '46efa3701b14f010a240ebd56e4bcbd4';
gs.info(getRoles(role_new,user_new));
getRoles: function(role,user)
{
var gr = new GlideRecord('sys_user_has_role');
gr.addEncodedQuery('role.name='+role+'^user='+user);
gr.query();
if(gr.hasNext())
{
return "found";
}
}
Any help on what is wrong is appreciated. Thanks:)
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 03:03 AM
Use
function getRoles(role,user) { var gr = new GlideRecord('sys_user_has_role'); gr.addEncodedQuery('role.name='+role+'^user='+user); gr.query(); if(gr.hasNext()) { return "found"; } }
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 03:37 AM
Thanks