The CreatorCon Call for Content is officially open! Get started here.

Hide service portal category item based on user group

thiraj
Tera Contributor

Hi team,

I want to hide a service portal category item for all users NOT belonging to a specific group. I have created a SCRIPT INCLUDE and a CATALOG CLIENT SCRIPT to do this task. I have successfully done it to hide the item for users with a specific service level. But i cannot seem to figure out how to do this for a group as i cannot use isMemberOf() in the client side. I have attached the screen shots i have done for the service levels. Please advise me on how i can hide the specific category item based on the user group.

This is the SERVER SIDE SCRIPT (Script Include)

find_real_file.png

This is the CATALOG CLIENT SCRIPT

find_real_file.png

All help is appreciated.

Thank you Team

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

Hi Thiraj,



gs.getUser().isMemberOf('<group name or sys_id>')       will work fine in your script include.


code in SI:


if(gs.getUser().isMemberOf('Premium Plus')){


return true;


}


return false;



Client Script ... code in display function...


var groupValue = response.respo ...........;


if(!groupValue){


        g_form.removeOption(. ... .. ;


}


View solution in original post

7 REPLIES 7

Gurpreet07
Mega Sage

Hi Thiraj,



gs.getUser().isMemberOf('<group name or sys_id>')       will work fine in your script include.


code in SI:


if(gs.getUser().isMemberOf('Premium Plus')){


return true;


}


return false;



Client Script ... code in display function...


var groupValue = response.respo ...........;


if(!groupValue){


        g_form.removeOption(. ... .. ;


}


Hi Gurpeet,



I gave it a try but it does not seem to work. I have attached the screenshots of the catalog client script and the script include.



Script include -



find_real_file.png



Catalog Client Script



find_real_file.png



Thank you


it should be group name , can you try with group name?


gs.getUser().isMemberOf('<group name>')


thiraj
Tera Contributor

Hi Srnewbie,



I have tried it with   group name as well but still no luck. I am not sure what i am missing here. According to my alerts it does not reach the inside of the if condition. Alert"here1" works fine. But the alert within the if condition does not get picked up. So i think it is something with the if condition or the answer coming back from the script include is incorrect. Please let me know what you think.



Thank you