- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 04:07 PM
I am developing a catalog and need to have one of the variables remain editable after the approvals are received. It only needs to be editable until the first task is completed. Right now, I am just trying to override setting the read only property after setting all the other variables to read only. The way I have it below is not functioning correctly. Any assistance would be greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 05:23 PM
Out of curiosity, if you edit the code to look like below, does it execute the way you'd like it to?
function onLoad() {
var stage = g_form.getValue('sc_req_item.stage');
if(stage == 'request_approved' || stage == 'completed'){
setTimeout(function () {
g_form.setVariablesReadOnly(true);
g_form.setReadOnly('legal_hold', false); //Revert legal hold to editable
g_form.setDisplay('legal_hold',true);
}, 500);
}
}
If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 07:56 PM
Ok, I realized I didn't try disabling the UI Policy after I made your changes. That seemed to work. But now it is allowing all of the variables on the SCTask to be editable. So I am going to do some more updates tomorrow to see if I can get it where it is just the legal_hold field that is editable. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 07:58 PM
Awesome! Glad you've made some headway. If tomorrow comes around and something gets stuck, come on back and we can keep working with it.
If I've at all helped, please return the favor by clicking the thumb next to my post. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 08:32 PM
Did you get a chance to check my below script?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 06:02 AM
Yes thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 07:14 PM
you can use Display business rule on sc_task table-> get the RITM stage using this
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
g_scratchpad.stage = current.request_item.stage.toString();
})(current, previous);
then use Normal onLoad client script on sc_task table and not Catalog client script
function onLoad() {
if (g_scratchpad.stage == 'request_approved' || g_scratchpad.stage == 'completed') {
setTimeout(function() {
g_form.setVariablesReadOnly(true);
}, 500);
g_form.setReadOnly('variables.legal_hold', false);
g_form.setDisplay('variables.legal_hold', true);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader