Validate logged in User is member of Specific Group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2022 06:10 PM
Hi I have a requirement if logged in user is member of specific group then I have a choice variable in catalog item with 2 options for eg: XYZ, and ABC . if the User is member of group A then I need to set a XYZ as a Default value or if user is member of Group B then I need to set the Value to ABC. How can I do this can anyone help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2022 07:17 PM - edited ‎11-03-2022 07:18 PM
You can use gs.isMemberOf('group_name') function to check that the logged is user is member of special group or not.
Write Script include where you check if user is member of Group A then return XYZ and if member of Group B then return ABC.
Now in default value of your choice variable call above script include as below:
javascript: new ScriptIncludeaName(). functionName();
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2022 08:27 PM - edited ‎11-03-2022 08:34 PM
Hi @Vamshi Krishna2 ,
Put a one liner script in your defalt value and it should work for you. Replace order support with your group name and xyz and abc with your option value:
javascript:gs.getUser().isMemberOf( "Order Support") ?"xyz":"abc"
Above script says if logged in user is member of Order support group then default option will be xyz if not then default option will be abc
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh