variables 'city' and 'state' should be visible to 'service' group member in catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 10:23 AM
variables 'city' and 'state' should be only visible to 'service' group members in catalog item, need to be hidden for all users
how can i achieve this
i saw some client script and script include and business rules but did not work , is this possible through catalog client script ?
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 10:25 PM
Hello @Purushotham9963
Please check this thread which will help you
Solved: Make Variables visible for certain group members - ServiceNow Community
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 10:34 PM
You have to write a catalog client script
1. Create Script Include with a method - to check if logged in user is member of the group or not.
Make Sure Client Callable is checked to true.
groupMemberCheck: function() {
var grp = this.getParameter('sysparm_group');
return gs.getUser().isMemberOf(grp);
},
2. Use below in your client script, OnLoad or OnChange according to your requirement.
var ga = new GlideAjax('Scriptincludename');
ga.addParam('sysparm_name', 'groupMemberCheck');
ga.addParam('sysparm_group', g_form.getValue('service'));
ga.getXML(groupMemberCheckXML);
function groupMemberCheckXML(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'true') {
//add logic here
}
}
You cannot acheive this with BR's as this is a catalog form.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2025 11:05 PM
2 ways to handle this
1) use onLoad client script + GlideAjax and check if logged in user is member of that group. if not then hide
OR
2) give that service group some unique role and then give that role in the Persmissions tab under those 2 city and state variable. no scripting required
Only users with that role will see that variable during catalog form submission
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2025 07:17 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader