To check logged in user is a manager on the basis of any other variable value

Poorva Bhawsar2
Tera Contributor

Hi Community,

 

I have a requirement in which i need to check logged in user is a manager or not based on a field value.

If xyz is "No" then i need to check logged in user is manager or not.

 

Is this possible? If yes, then please provide me the code for the same.

 

Thanks,

Poorva Bhawsar

2 REPLIES 2

Kalyani Jangam1
Mega Sage
Mega Sage

Hi @Poorva Bhawsar2 

In Before update you can use below code

 

if(current.impact==3) { // ex xyz=NO
if (gs.getUser().hasRole('sn_audit.manager')) {
gs.addInfoMessage("In Manager Loop-------");
//current.addEncodedQuery('impact=3');
}
}

 

If it is Before Query then below code will work

var num = current.getTableName();
var gr = new GlideRecord(num);
gr.addEncodedQuery('impact=3'); //XYZ=No
gr.query();
while (gr.next()) {
gs.addInfoMessage("In Low Impact*************"+gr.getRowCount());
if (gs.getUser().hasRole('sn_audit.manager')) {
gs.addInfoMessage("In Manager Loop-------");
//current.addEncodedQuery('impact=3');
}
}

Please check and let me know if it helpful or not.

This is for a catalog item variable, I need a client script for this. Just if xyz has No then need to check logged in user is a manager or not.