How to make RITM and SCTASK variable fields read only after RITM is approved?

Jeremy F_
Giga Expert

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.

find_real_file.png

find_real_file.png

function onCondition() {
var ritm = 'current';
	var approved = new GlideRecord('sc_req_item');
	approved.addQuery('stage', ritm);
	if(stage == Fullfillment){
		g_form.setVariablesReadOnly(true);
	}
}
1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader