- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2020 05:11 AM
I have a multiple choice variable that I want to prevent the itil role from being able to modify when it is visible on the task form but I want itil users to be able to add the item and set the choice at the request level.
I set the Write roles to itil_admin but that prevented an itil user from seeing the variable on the task form.
When I try to set itil role to Read roles it won't let me unless I first clear Write roles
I'm a bit confused as to what the logic is here!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2020 05:23 AM
Hi,
So the variable permissions carry on after the catalog item, wherever it is shown. So if you have one scenario where you want that role to be able to write, but then not write over here...this permission section won't help you.
My suggestion would be to simply make a UI Policy for this variable, select the "applies on Task" checkbox, and then set that variable to read-only = true.
That way, they can write to it elsewhere, but not on the task level.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2020 07:11 AM
I'm still having some trouble wth this.
The variable I want to set to read only is 'model_of_computer'
I am testing with a user who has ITIL role
The catalog condition is
model_ofcomputer is anything (which I'm assuming will always resolve to true as long as one choice was selected).
Scripts are enabled and Execute if true is as follows
function onCondition() {
gs.log("RGK - true 1");
if (g_user.hasRole("itil"))
g_form.setReadOnly("model_of_computer", true);
else
g_form.setReadOnly("model_of_computer", false);
gs.log("RGK - true 2");
}
I'm not getting any log output so the UI Policy is not triggering.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2020 07:21 AM
LOL - looks like my logic is back to front 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2020 07:37 AM
Hi Rich,
gs.log() is a server side function. Try using g_form.addInfoMessage() instead. Since you are in a dev/test environment it shouldn't matter that the messages will be on screen.
I suspect that what you'll find with that in place is if you right click on the form header bar (not the zebra stripes), you will get the browser context menu and not the ServiceNow context menu. That's one quick way to tell that a client side script is misbehaving.
Hope that helps.
:{)
Helpful and Correct tags are appreciated and help others to find information faster
:{)
Helpful and Correct tags are appreciated and help others to find information faster

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2020 07:47 AM
Sorry, you had my reply marked as Correct so I didn't catch this until now.
As a side note, if you have the field set to "is anything" then even none counts (just mentioning for the record). So really this will instantly take place onLoad I would imagine.
As John mentioned gs.log won't run in a UI Policy/Client Script, you'd want to show an "alert" maybe for a quick way to assess this. You could also test this right on the catalog item instead of it going all the way to the task (just for testing).
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2020 08:01 AM
Thanks to both. I've changed to an addInfoMessage which is speeding things up a bit!
OK so leaving the condition empty causes it to evaluate to true. Hopefully I should be able to sort it out now.
Many thanks.