Add condition to client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 08:56 AM
Hi All,
I have 2 OOB client scripts - Variable Editor Readonly
on RITM and SC TASK table.
This is making all variables read-only on RITM and sc task.
Requirement is to restrict these 2 client scripts only to few catalog items. (where catalogs = Procurement).
How can i add this condition to the client scripts?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 09:15 AM
Hi Anurag,
Not sure if i fully understood the solution here. could you please expand?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 09:18 AM
@dvelloriy You can write a display business rules on RITM and SC_Task tables and put the condition mentioned by Anurag in the script. Then set a g_scratchpad variable accordingly (True/false) and check this variable inside your client script. To know more about display business rule, please refer to https://www.servicenow.com/community/developer-articles/display-business-rule-and-g-scratchpad/ta-p/....
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 12:13 PM
Sandeep, i would need further help in defining the scratchpad variable.
So I need to create a Display BR on SC TASK
1. I will add a condition Request Item. Item. Catalogs = Procurement
2. Under Advance section, i will add add a script to initiate scratchpad variable.
g_scratchpad.value = "true";
3. Then in my global client script, i will insert scratchpad created above:
function onLoad() {
//Type appropriate comment here, and begin script below
if(g_scratchpad.value = "true") {
g_form.setVariablesReadOnly(true);
}
}
Will this work? Please advise.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 12:16 PM - edited 08-01-2024 12:17 PM
@dvelloriy Yes, ideally this will work added a small change in the script.
function onLoad() {
//Type appropriate comment here, and begin script below
if(g_scratchpad.value == "true") {
g_form.setVariablesReadOnly(true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2024 12:59 AM
Guess you are covered, do you still have any more question?