How can i restrict the access of incidents specific assigned to group xyz only to it's group members

Sowmya20
Tera Contributor

Hi,

 

I have requirement if incident assignment group is "XYZ" security checkbox is true. Then only part of the assignment group member incident ticket should visible. Other team should not have access to view these tickets.

 

Thanks in advance.

 

23 REPLIES 23

Siddhesh Gawade
Mega Sage
Mega Sage

You can write below code: 

 

 

(function executeRule(current, previous /*null when async*/) {

// Check if the user is a member of 'XYZ' assignment group
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', gs.getUserID());
gr.addQuery('group.name', 'XYZ');     // Preferable use group sys_id for query
gr.query();

// If the user is not a member of 'XYZ' assignment group, add a condition to the query
if (!gr.next()) {
current.addQuery('assignment_group', '!=', 'XYZ');
current.addQuery('security',  '!=','true');
}

})(current, previous);

 

 

Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.


Regards,

Siddhesh

AndersBGS
Tera Patron
Tera Patron

Hi @Sowmya20 ,

 

Please create a before query business rule as below:

AndersBGS_0-1704366213032.png

 

In the advanced tab condition you should set 

!gs.getUser().isMemberOf('XYZ');

In the script field set (replace the sysid with your assignment group (XYZ) sysID:

(function executeRule(current, previous /*null when async*/ ) {
var grp = current.addNullQuery('assignment_group').addOrCondition('assignment_group','!=','8a5055c9c61122780043563ef53438e3');
})(current, previous);

Above will only filter out the assignment group, so the code need to be altered a bit according to the checkbox.  

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

gulu
Tera Contributor

hey i have tried this but does not work for some reason.  it does hide the ticket for folks not in the group but when i belong to the group it shows all tickets.  I want all groups to not be able to see the ticket and then i want the person that belongs to the group to only see there own groups tickets only.

 

thanks

Community Alums
Not applicable

This BR worked for me in trying to block other groups from seeing one groups incidents. Only issue now, how do I change the confirmation message on the service portal, that is generated when an INC is created to the  group that does not want their incidents visible to others? Currently the message is "Sorry, either the data doesn't exist or you don't have access"... 

How can change this ensure the user that their incident has been created to the group who's incidents are blocked from view?