- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 06:14 AM
Hi Experts,
Good Day!
I am trying to make one variable on catalog item to one particular person or one particular group.
For example: the variable name is Request type, this should be visible only to one user or one assignment group.
Could you please assist me with this.
Best Regards,
Atchut ram
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 06:24 AM
Hi,
There is also the possibility to set Permission on the variable.
You can add which roles should have access to the variable, and give that role only to a specific group/person.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 06:17 AM - edited 11-30-2022 06:18 AM
Hello @Atchutaram,
Please write a on load client script to check the user Id of the user and then check if it matches with your required user. You can also check if the logged in user is a member of required group.
and depending on the above condition show or hide the field.
Please let me know if you require script as well.
Please mark it as correct.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 06:26 AM
Hi nayan,
Could you please provide the script as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 09:51 PM
Hello @Atchutaram ,
Please use the below scripts to hide for user :
Write a display business rule to store the values in scratchpad:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
g_scratchpad.isMemberOfITSAPECC = gs.getUser().isMemberOf('your group name'); //to check member of group
g_scratchpad.myTest = gs.getUserID() == 'sys_id of user'; // to check logged in user
})(current, previous);
Then call the above BR in client script:
function onLoad() {
var myVariablesAreReadOnly = true;
if((g_scratchpad.isMemberOfITSAPECC ) // or you can also check for logged in user same as done here.
{
myVariablesAreReadOnly = false;
}
g_form.setReadOnly("variables.u_sap_short_description", myVariablesAreReadOnly);
}
Please mark as correct if it helps.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 06:18 AM
Hi,
You can use the load client scripts.
Take a look at old thread -
Is there a way to hide/show a variable based on the current user's group?
Hiding Catalog Item Variables based on Group Membership
Thanks,
Sagar Pagar