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.

Getting Error in Widget

Michael48
Tera Contributor

I have a code am working on where i want users with a specific role should be able to view the records in the query below. it seems to be working but its throwing the error in the screen shot.

 

Here is the code

 

var gr = new GlideRecord('x_verw2_ac_factory_af_opportunity');
gr.addQuery('u_state','!=','Draft');//only draft records should be visible
var grOr= gr.addQuery('u_requested_by' , gs.getUserID());
grOr.addOrCondition('requester_delegate',gs.getUserID());
grOr.addOrCondition(gs.getUser.hasRole("x_verw2_ac_factory.super_user")); //(my line of script that's throwing the error)
 
gr.query();
 
 
while(gr.next()){
del.push(gr.number.toString());
 
}
11 REPLIES 11

If the user has this role x_verw2_ac_factory.super_user they should all records that is not in draft state but if they dont have that role they should the  records where there they are the requester or delegate of

i observed now that it just keeps searching when you have the role, it doesnt load the data in the drop down.