How to show incidents to users only if they are part of current assignment group?

vidishaagarwal5
Tera Expert
 
1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage
Giga Sage

Hi @vidishaagarwal5 

 

you can use ACL

 

IN ACL Script : if(gs.getuser().isMemberOf('current.assignment_group'){ answer=ture; }else{ answer=false }

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

3 REPLIES 3

ChallaR
Mega Guru

Hi @vidishaagarwal5 ,

 

you have create a ACL , please find the step by step process for that -

1. Create or Modify an Access Control Rule

  • Navigate to System Security > Access Control (ACL).
  • Create a new ACL or modify an existing one for the Incident table.
  • Set the Type to record.
  • Set the Operation to read.

2. Set the Condition or Script

You have two options:

Option A: Condition-Based ACL

Use a condition like:

Assignment Group is one of javascript:getMyGroups()

NOTE -Where getMyGroups() is a custom function or dynamic filter option that returns the groups the current user belongs to.

Option B: Script-Based ACL

Use a script like this:

var userGroups = gs.getUser().getMyGroups();
var incidentGroup = current.assignment_group;

if (incidentGroup == null) {
    answer = false;
} else {
    answer = userGroups.indexOf(incidentGroup.sys_id.toString()) != -1;
}

 

This script checks if the current user's groups include the assignment group of the incident.

 

Please nark as complete and close the thread if this is helpful.

 

Thanks,

Rithika.ch 

 

Nawal Singh
Tera Guru

Hi @vidishaagarwal5 ,

 

You need to write Query Business rule like below- 

 

NawalSingh_0-1761637003787.png

and in advanced tab need to write script logic- 

 

NawalSingh_1-1761637049952.png

 

Here is the code- 

 

   var userGroups = [];
    var grMember = new GlideRecord('sys_user_grmember');
    grMember.addQuery('user', gs.getUserID());
    grMember.query();
    while (grMember.next()) {
        userGroups.push(grMember.group.toString());
    }

    // Restrict query to only incidents assigned to those groups
    if (userGroups.length > 0) {
        current.addQuery('assignment_group', 'IN', userGroups);
    } else {
        // If user is not in any group, show nothing
        current.addQuery('sys_id', 'EMPTY');
    }

 

Please test this code I have tested in PDI it's working fine.

 

If you found my response helpful, please mark it as helpful and accept it as the solution.

Thank you
Nawal Singh

Ravi Gaurav
Giga Sage
Giga Sage

Hi @vidishaagarwal5 

 

you can use ACL

 

IN ACL Script : if(gs.getuser().isMemberOf('current.assignment_group'){ answer=ture; }else{ answer=false }

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/