How restrict particular RITM records using Query Business Rule

Aparna Gurav
Tera Contributor

Hello Team, 

 

I want to hide particular RITMs created from the specific catalog item using the Query Business rule for all users and it shows visible to only specific Groups

 

I created a Business rule But it's not working as expected, Still, non-specified group members see that RITM

 

AparnaGurav_0-1683115038689.png

 

AparnaGurav_1-1683115096329.png

 

1 ACCEPTED SOLUTION

Try this

 

 

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

if (!(gs.getUser().isMemberOf('7547606d879e4d1080bba8a90cbb3595') || gs.getUser().isMemberOf('2dd2fa7f87922d50a4a486e40cbb3589'))) {

current.addEncodedQuery('cat_item!=858476ff87922d50a4a486e40cbb3571');
}


})(current, previous);

 

Also, once you get the script working, try to avoid the hardcoded sys_id

 

-Anurag

View solution in original post

8 REPLIES 8

Community Alums
Not applicable

Hello @Aparna Gurav ,

 

Are you providing the groups name which have access or the groups who don't have access.

Check your if condition , use gs.info() to log the information and check whether your condition working or not.

 

If this solves your query mark this as correct.

 

Regards

Anand

@Community Alums : Thanks for the Response.
If the user is not a member of these groups, they will not have access to view the requested item in the catalog.

 

Devender Kumar
Tera Guru
Tera Guru

Hello Aparna,

Remove the filter condition Item is from when to run tab.

Change the code like below in your script.

if(gs.getUser().isMemberOf('sys_id of group1') || gs.getUser().isMemberOf('sys_id of group2'))
{
current.addQuery('cat_item','sys_id of catalog item);
}

 

Please mark my answer as helpful/correct if it helps you.

Regards,

Devender

@Devender Kumar : I adjusted my script, But It's not working as expected

 

I want If the user does not belong to these groups then they can not see the requested item for that catalog item

Is any still adjustment required?

 

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

// Add your code here
if (!gs.getUser().isMemberOf('7547606d879e4d1080bba8a90cbb3595') || !gs.getUser().isMemberOf('2dd2fa7f87922d50a4a486e40cbb3589')) {

current.addEncodedQuery('cat_item!=858476ff87922d50a4a486e40cbb3571');
}


})(current, previous);