incident display based on user's group

MK-p
Tera Contributor

i have a requirement to display only those incidents on which logged in user belongs to group.

example, if i belongs to x,y,z group then i should see only incident which has group x,y,z.

2 ACCEPTED SOLUTIONS

Runjay Patel
Giga Sage

Hi @MK-p ,

 

You can create display query business rule and below query.

current.addEncodedQuery('assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744')

This query help you to display on of your group.

 

RunjayPatel_0-1736404015063.png

 

RunjayPatel_1-1736404038818.png

 

 

 

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

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

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

 

View solution in original post

@MK-p 

Thank you for marking my response as helpful.

Are you planning to remove the existing incident query BR and create a new one?

I believe I also provided you the correct approach by modifying existing OOB Query BR on incident table.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Runjay Patel
Giga Sage

Hi @MK-p ,

 

You can create display query business rule and below query.

current.addEncodedQuery('assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744')

This query help you to display on of your group.

 

RunjayPatel_0-1736404015063.png

 

RunjayPatel_1-1736404038818.png

 

 

 

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

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

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

 

Deepak Negi
Mega Sage
Mega Sage

Use ACLs

 

Create table level read ACL for incident.
Apply conditions

 

Assignment Group (is)(dynamic) One of my Groups

 

DeepakNegi_0-1736404074998.png

 

Thats it!

 

Ankur Bawiskar
Tera Patron
Tera Patron

@MK-p 

Remember OOB there is already a Query BR on incident table

Why not enhance that? Also you will have to check and update the condition in table level READ ACL

Line 24 is newly added

restrictIncidents();

function restrictIncidents() {
    if (!gs.hasRole("itil") && !gs.hasRole("sn_incident_read") && gs.isInteractive()) {
        //Do NOT restrict Incidents if SPM premium plugin is active AND user has the service_viewer role.
        if (GlidePluginManager.isActive('com.snc.spm') && gs.hasRole('service_viewer'))
            return;
        if (GlidePluginManager.isActive('sn_fsm_itsm_mng') && gs.hasRole('wm_ext_agent'))
            return;
        // STRY52118544: ham_user is added to support incident read for reporting on HAM store app
        if (GlidePluginManager.isActive('com.sn_hamp') && gs.hasRole('sn_hamp.ham_user')) {
            return;
        }
        // DEF0330091: Allow query on OT Incident with sn_ot_incident_read role
        if (GlidePluginManager.isActive('com.sn_ot_inc_mgmt') && gs.hasRole("sn_ot_incident_read"))
            return;

        // Responders should be able to access all incidents 
        if (gs.hasRole("sn_sow_srm.srm_responder")) {
            return;
        }

        var u = gs.getUserID();
        var groups = new global.ArrayUtil().convertArray(gs.getUser().getMyGroups());
        current.addQuery('assignment_group.sys_id', 'IN', groups.toString());
        current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("watch_list", "CONTAINS", u);
    }
}

ACL to be updated with below condition: https://instanceName.service-now.com/nav_to.do?uri=sys_security_acl.do?sys_id=7da3bda1c0a801667dc88c1e9527f776

AnkurBawiskar_0-1736405660144.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@MK-p 

Thank you for marking my response as helpful.

Are you planning to remove the existing incident query BR and create a new one?

I believe I also provided you the correct approach by modifying existing OOB Query BR on incident table.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader