How to set RITM fields readonly through Business rule

Datta Pisal1
Tera Contributor

Hi All,

I have below scenario and need help for this,

i am creating a change and ctask through service catalog request.

 so brought  a field called parent (Requested item backend name :parent.parent) on Ctask form and i need to make its variables readonly after ctask closed (for testing taken target_ci variable only). so thinking to do it through business rule but it is not working, Please help me to solve this.

 

Conditon : After update , status is closed

 

Script:

(function executeRule(current, previous /*null when async*/) {

var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.parent.parent);
gr.query();

if(gr.next()){

gr.setReadOnly('gr.variables.target_ci',true);

gr.update();
}

})(current, previous);

 

Thanks & Regards

7 REPLIES 7

Anil Lande
Kilo Patron

Hi,

You cannot make fields Read only using business rule. Business rule work on Server side and you can only perform server side (backend) operations using business rule.

 

To make field read only you can use client script and UI policies.

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Anil Lande
Kilo Patron

Create catalog client script or UI policies. Make sure it will be execute only on Catalog task by checking checkbox as shown below link:

https://www.servicenow.com/community/it-service-management-forum/make-variables-readonly-in-one-task...

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi Anil,

Thank you for your reply, could you help to build below scenario.

I have requirement to set ritm variables read only after closing ctask so how I can achieve this.

 

DattaPisal1_0-1664876306511.png

Regards,

Datta

 

Mahendra RC
Mega Sage

Hello @Datta Pisal1 

You cannot make the fields readonly using the Business rule.

1. You can make the fields read only at server side using the ACL or Data policy

2. You can make the field read only at client side using UI Policy or Client script.

Please share your exact requirement when do you want to make the field read only.