- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 02:47 AM
Hello,
Could you please suggest, how to make the particular variables read-only, when all catalog task get closed.
If one catalog is open state and another catalog task is closed state, then the variable should be editable for both the task.
If both the catalog task are in closed state, then only the variable should be in read-only state in both the task.
I written below code in catalog client script on onload form applied to catalog task and Requested item.
But the request item variables are not making read-only, when ritm is close complete.
function onLoad() {
var ritm = g_form.getReference('request_item', callBackMethod);
alert("ritm");
}
function callBackMethod(ritm) {
if (ritm.state == '3' || ritm.state == '4' || ritm.state == '7') {
alert("testing");
g_form.setVariablesReadOnly(true);
}
}
Could you please help on this issue.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 10:10 PM
try to update script as this to make it work for sc_req_item and sc_task
function onLoad() {
if(g_form.getTableName() == 'sc_task')
var ritm = g_form.getReference('request_item', callBackMethod);
else{
var state = g_form.getValue('state');
if (state == '3' || state == '4' || state == '7') {
g_form.setVariablesReadOnly(true);
}
}
}
function callBackMethod(ritm) {
if (ritm.state == '3' || ritm.state == '4' || ritm.state == '7') {
alert("testing");
g_form.setVariablesReadOnly(true);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 03:15 AM
Hi,
Whats the use case behind this requirement?
Why would you want users to change the variables on a task that's already closed?
It would be fairly simple to create a UI policy to set the variables to read-only if the state of the task itself is set to closed.
But if you need to check on other records (other tasks), you would need to do some GlideAjax and use a scriptinclude to check if the variables should be set to readonly or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 03:38 AM
Hello
We have a requirement when first catalog task is closed state and another catalog task is open state, then the variable should be editable for both the task.
Even one task is in open states, then variables should be editable.
Both tasks should be in closed state, Then only the variable is read-only state.
Can we have any sample example to creating Script include and Glide Ajax for making variable read-only when all task get closed.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 05:45 AM
I understood your requirement.
What I was asking for is why.
Why do you want to allow users to edit variables on a task that is closed?
A good starter for learning GlideAjax can be found here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 09:54 PM
Hello
I written below code to make the variables read-only when request item is close complete.
Written code on catalog client script onload function used.
Applied this code on Requested item and catalog task.
function onLoad() {
var ritm = g_form.getReference('request_item', callBackMethod);
alert("ritm");
}
function callBackMethod(ritm) {
if (ritm.state == '3' || ritm.state == '4' || ritm.state == '7') {
alert("testing");
g_form.setVariablesReadOnly(true);
}
}
But it is working for Catalog task and not working for Ritm, if you have any idea. please help on this.