- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2015 06:13 AM
Hello all,
Currently I have a client script that makes it so users are unable to change variables at the RITM level. What I am looking to do is add a list (u_users_with_access) on my catalog item that references the user table which would allow me to list certain users that should have rights to modify the data on that RITM. Any help would be appreciated.
My current client script is the following;
Table: Requested Item
Type: onLoad
function onLoad(){
$(variable_map).select("item").each(function (elmt)
{
try {
g_form.setDisabled('variables.' + elmt.getAttribute('qname'),true);
}
catch (err)
{
}
}
);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2015 06:22 AM
Hi Steven,
I think you could check if the user is a part of the list using a display business rule and then set the value in a scratchpad variable.
so, your display business rule would be like
g_scratchpad.restrict_edit = true;
if(current.cat_item.u_users_with_access.toString().indexOf(gs.getUserID()) != -1) {
g_scratchpad.restrict_edit = false;
}
In your script above, just add below check
if(g_scratchpad.restrict_edit) {
$(variable_map).select("item").each(function (elmt)
{
try {
g_form.setDisabled('variables.' + elmt.getAttribute('qname'),true);
}
catch (err)
{
}
}
);
}
Hope that helps.
Mandar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2015 06:18 AM
Hi Steven,
You can add an if condition to the existing client script to restrict it based on users/roles. Please let me know if you have any questions.
Please check section 3.3 for ex.
GlideUser (g user) - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2015 06:20 AM
I was thinking it'd be easier to do it using ACLs but i actually can't think of a way to utilize ACLs to restrict access to variables. So, maybe you can create a role for that functionality and in your script just utilize the g_user.hasRole() method to check and go from there.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2015 06:22 AM
Hi Steven,
I think you could check if the user is a part of the list using a display business rule and then set the value in a scratchpad variable.
so, your display business rule would be like
g_scratchpad.restrict_edit = true;
if(current.cat_item.u_users_with_access.toString().indexOf(gs.getUserID()) != -1) {
g_scratchpad.restrict_edit = false;
}
In your script above, just add below check
if(g_scratchpad.restrict_edit) {
$(variable_map).select("item").each(function (elmt)
{
try {
g_form.setDisabled('variables.' + elmt.getAttribute('qname'),true);
}
catch (err)
{
}
}
);
}
Hope that helps.
Mandar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2015 09:54 AM
Thanks Mandar! That worked perfectly!