Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Revoke group access based on the incident.

srinathgtrk
Tera Contributor

Hi Everyone,

 

Group: Incident User Group

 

If User is not part of any incident (for example user don't have any incident in his bucket) should be removed from above group (Incident User Group).

 

Thanks,

Srinath Kolipakula

12 REPLIES 12

Samaksh Wani
Giga Sage

Hello @srinathgtrk 

 

Can you tell on which event it should trigger.

it will trigger whenever assigned to field changed in incident table.

Share the script, did you pass the sys id of group?

Execute below:

Var grMem  = new GlideRecord('sys_user_grmember');
grMem.addQuery('group.sys_id', ' ' ); // Pass the sys_id of Incident User Group
grMem.query();
while(grMem.next())
{
var inc = new GlideRecord('incident');
inc.query('assigned_to',grMem.user);
inc.query();
if(inc.getRowCount==0)
{
grMem.deleteRecord();
}
}