To set parent_incident field read-only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2025 07:05 AM
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)
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2025 10:55 AM
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2025 07:25 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2025 07:32 PM
I only want this on onload but if I used ui policy it will work both on onchange and onload
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2025 05:45 AM
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]
****************************************************************************************************************