Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

variables read only on RITM record

Basina Akash
Tera Contributor

How to set Variables read- only on the RITM record form on default view

2 ACCEPTED SOLUTIONS

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Basina Akash 

 

You want to make read only after Submit , if yes then 

https://www.servicenow.com/community/itsm-forum/set-variables-readonly-on-ritm/td-p/834889

https://www.servicenow.com/community/developer-forum/make-the-ritm-catalog-task-variables-read-only/...

https://www.servicenow.com/community/now-platform-forum/should-variables-carried-over-to-the-ritm-be...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

Robbie
Kilo Patron
Kilo Patron

Hi @Basina Akash,

 

The best practice would be to leverage a UI Policy and set each field/variable read-only.

You also have the option to leverage the g_form.setVariablesReadOnly(true) method via an onLoad Client Script.

This method is specifically reserved for the sc_task and the sc_req_item table. (It will not work with any other table)

 

If you are trying to make the variable read-only on the Variable Editor, use the below script via an onLoad Client Script.

 

function onLoad() { 
$("variable_map").querySelectorAll("item").forEach(function(item){
var variable = item.getAttribute("qname"); 
g_form.setReadOnly("variables."+ variable, true); 
}); 
}

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

Further details and ServiceNow documentation can also be found here:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0752560

View solution in original post

4 REPLIES 4

nirwan_ritik
Tera Contributor

Hi Akash,

 

On the catalog item you are configuring, check related tabs for variables. Locate and open the variable you want to make read only. From there, check the read only checkbox.

nirwan_ritik_0-1705487506697.png

 



Mark my answer helpful and solution proposed if this helped.
Thanks 🙂



Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Basina Akash 

 

You want to make read only after Submit , if yes then 

https://www.servicenow.com/community/itsm-forum/set-variables-readonly-on-ritm/td-p/834889

https://www.servicenow.com/community/developer-forum/make-the-ritm-catalog-task-variables-read-only/...

https://www.servicenow.com/community/now-platform-forum/should-variables-carried-over-to-the-ritm-be...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Robbie
Kilo Patron
Kilo Patron

Hi @Basina Akash,

 

The best practice would be to leverage a UI Policy and set each field/variable read-only.

You also have the option to leverage the g_form.setVariablesReadOnly(true) method via an onLoad Client Script.

This method is specifically reserved for the sc_task and the sc_req_item table. (It will not work with any other table)

 

If you are trying to make the variable read-only on the Variable Editor, use the below script via an onLoad Client Script.

 

function onLoad() { 
$("variable_map").querySelectorAll("item").forEach(function(item){
var variable = item.getAttribute("qname"); 
g_form.setReadOnly("variables."+ variable, true); 
}); 
}

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

Further details and ServiceNow documentation can also be found here:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0752560

Iraj Shaikh
Mega Sage

Hi @Basina Akash 

You can set the variable read-only by creating catalog UI policy for your catalog item.

 

IrajShaikh_1-1705487712112.png

 

Create catalog UI Policy and catalog UI Policy action as shown below

IrajShaikh_0-1705487604417.png

 

Select your catalog item name of your variable that needs to be set read-only in 'Catalog item' field.
Select 'Applies on Requested Items' checkbox
Create UI Policy Action for your variable as shown above

Please mark this response as correct or helpful if it assisted you with your question.