Change Model- Available for and Not Available for User criteria

Ashwin Perumal1
Tera Contributor

 

Scenario:

If a Assignment group has manager empty then for those users we should restrict the visibility of Emergency Change Model in Change Landing Page. In vice versa If Assignment group has manager not empty then for those users Emergency Change model should be visible in Change Landing Page. I added the below code under Available for related in Change model user criteria

 

var rec = new GlideRecord('sys_user_grmember');
rec.addQuery('user', user_id);
rec.addEncodedQuery('group.managerISNOTEMPTY');
rec.setLimit(1);
answer = rec.hasNext();

 

The above code also didn't work ..no logs were also displayed even when i gave log messages. Can you please help me what's the mistake in code and why my change model is not been restricted properly

2 ACCEPTED SOLUTIONS

Harsh_Deep
Giga Sage
Giga Sage

Hello @Ashwin Perumal1 ,

 

Use this script-

answer = false;
var user = gs.getUserID();
var rec = new GlideRecord('sys_user_grmember');
rec.addEncodedQuery('user='+user+'^group.managerISNOTEMPTY');
rec.query();
if(rec.next())
{
	answer = true;
}

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

View solution in original post

Hello @Ashwin Perumal1 

 

It will work for the all scenarios. If user is part of any group and that group is having manager then it will work.

If that user is a member of multiple group and all the groups are not having manager then it will not be visible.

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

 

 

View solution in original post

4 REPLIES 4

Harsh_Deep
Giga Sage
Giga Sage

Hello @Ashwin Perumal1 ,

 

Use this script-

answer = false;
var user = gs.getUserID();
var rec = new GlideRecord('sys_user_grmember');
rec.addEncodedQuery('user='+user+'^group.managerISNOTEMPTY');
rec.query();
if(rec.next())
{
	answer = true;
}

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

Hi Harsh,

The above script works in one scenario if the user is part of one group. In that case it works fine. But coming to other scenario if a user is part of multiple groups and one group he is having manager and another group he is not having manager in that case the above script its not working as expected. 

If a user is having atleast manager in any one of the groups he is tagged then in that scenario also my Change model should be vissible. Can you pls help me to code the mentioned scenario. Thanks in advance

Hello @Ashwin Perumal1 

 

It will work for the all scenarios. If user is part of any group and that group is having manager then it will work.

If that user is a member of multiple group and all the groups are not having manager then it will not be visible.

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

 

 

Thanks Harsh it worked fine