To set parent_incident field read-only

Subham_
Tera Contributor

I got a requirement to make parent_incident field Read only when a form is saved on resolved state

For this I wrote a onload script but not worked

Script:-

If(g_form.getValue('state')==6){

g_form.setReadonly('parent_incident', true)

}

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Subham_ 

 

You can use UI policy which is low code/no code.

 

State = Resolved and in UI action make it 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]

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

Hi @Dr Atul G- LNG ,

 

Thanks for the advice.

But I need on onload and ui policy work on onload and change also

But I need on onload only.

Subham_
Tera Contributor

I only want this on onload but if I used ui policy it will work both on onchange and onload 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Subham_ 

 

(function executeRule(current, gForm, gSNC)

{ if (current.state == 6) { // 6 is the 'Resolved' state

gForm.setReadOnly('parent_incident', true); } })(g_form.getValue('state'));

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

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