Manually Lock variables on RITM form

Joshuu
Kilo Sage

Hi All,

 

We have made all the variables of a specific catalog item editable on RITM form. Can we configure a button to manually lock all the variables?

 

Thanks & Regards.

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Joshuu 

 

What is use case for this? You can do but it will be customization. Need to create UI action and set all the variables and make read only. 

*************************************************************************************************************
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]

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

Rajdeep Ganguly
Mega Guru


Yes, you can configure a button to manually lock all the variables on a Requested Item (RITM) form. Here are the steps to do it:

1. Create a UI Action on the RITM table.
2. Set the UI Action to be a "Form Button".
3. In the script section of the UI Action, write a script to lock all the variables. You can use GlideRecord to get the current RITM and then use GlideElement's setReadonly method to set all variables to read-only.

Here is a sample code:

javascript
var gr = new GlideRecord('sc_req_item');
gr.get(current.sys_id);
var itemVariables = gr.variables;
for (var i = 0; i < itemVariables.getCount(); i++) {
var variable = itemVariables.get(i);
variable.setReadonly(true);
}
gr.update();


4. Save the UI Action.
5. Now, when you open a RITM form, you should see a new button. When you click this button, all the variables on the form will be locked.

Please note that this is a simplified example and you might need to adjust it to fit your specific needs. Also, keep in mind that making a variable read-only will prevent users from changing its value, but it won't prevent scripts or system processes from changing it.


nowKB.com

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/

For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

Hi @Rajdeep Ganguly ,

 

Thank you for your response. I have added the UI action but it is not working.

 

priyarao_0-1708434003181.png

 

Bcz the response were generated from ChatGPT. 

*************************************************************************************************************
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]

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