- 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 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 11:01 PM
Thank you so much Ankur, this script is worked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2022 11:14 PM
Glad to know.
Please mark response helpful as well.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader