How to make RITM and SCTASK variable fields read only after RITM is approved?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2021 03:41 AM
Hello,
I've read through many posts trying to find a solution for this, but have not been able to figure it out. Instead of sending approval requests for Requests (REQ are all automatically approved), we send approval requests for Requested Items (RITM). We have only 2 RITM types that the RITM and SCTASK variable fields must be read only after the RITM has been approved. The RITM stage goes into Fulfillment after approval, so I have been trying to leverage the "Stage" field on the RITM form to trigger making the RITM and SCTASK variables read only. I think this is possible, but I haven't been able to get the Catalog UI Policy script right.
function onCondition() {
var ritm = 'current';
var approved = new GlideRecord('sc_req_item');
approved.addQuery('stage', ritm);
if(stage == Fullfillment){
g_form.setVariablesReadOnly(true);
}
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2021 03:48 AM
Hi,
If your UI policy is running on Catalog task then update as this
Set UI Type - ALL
ensure you use proper value for Fulfillment
function onCondition() {
var ritm = g_form.getValue('request_item');
var approved = new GlideRecord('sc_req_item');
approved.addQuery('sys_id', ritm);
approved.query();
if(approved.next()){
if(approved.stage == 'Fulfillment'){
g_form.setVariablesReadOnly(true);
}
}
}
If you wish to check if RITM is approved then do this directly
function onCondition() {
var ritm = g_form.getValue('request_item');
var approved = new GlideRecord('sc_req_item');
approved.addQuery('sys_id', ritm);
approved.query();
if(approved.next()){
if(approved.stage == 'request_approved'){
g_form.setVariablesReadOnly(true);
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader