ITSM

sushma9
Tera Contributor

Hi All ,

 I have a requirement to hide the records based on the assignment group and i have assignment group " A " and  if the user is part of that group  he has to see the only the tickets assigned to that group ( A) and if the user is part of any another group they dont want to see the records that assigned to that assignment group (A) . Admin has to see the all the records irrespective of any groups . 

I have return the query Br to  hide them .Please find the script below .

Note : Admin role user can see all the records and users part of group A has to see only the tickets assigned to that group . If the user part of deferent group he should not see the tickets assigned to group A.

Script :

if ((gs.getUser().isMemberOf("7bdd041f978f31106e83bd0de053af0f")) || gs.hasRole('admin')) {
       current.addQuery("assignment_groupDYNAMIC7bdd041f978f31106e83bd0de053af0f");
}else {
current.addQuery("!assignment_groupDYNAMIC7bdd041f978f31106e83bd0de053af0f");
}
 
sushma9_0-1702740781409.png

 

1 ACCEPTED SOLUTION

@sushma9 Simply replace your script with the following.

 

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

	// Add your code here
	if(!gs.hasRole('admin')){		
		current.addEncodedQuery('assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744');
	}

})(current, previous);

Please mark the answer correct and helpful if it addresses your issue.

View solution in original post

2 REPLIES 2

sushma9
Tera Contributor

Hi All,

when i am changing the script i am getting below result 

Script :

 if ((gs.getUser().isMemberOf("7bdd041f978f31106e83bd0de053af0f"))) {
        //
       current.addEncodedQuery("assignment_group", '=', "7bdd041f978f31106e83bd0de053af0f");
    }else if (gs.hasRole('admin')){
        // nothing
    }
Results : user part of that group able to see the tickets assigned to that group and admin user able to see all the records  but the users part of different group  are not able to any see records on the table.
sushma9_0-1702741476609.png

 Please let me know if anything has to be modified in the script section.

@sushma9 Simply replace your script with the following.

 

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

	// Add your code here
	if(!gs.hasRole('admin')){		
		current.addEncodedQuery('assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744');
	}

})(current, previous);

Please mark the answer correct and helpful if it addresses your issue.