- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 07:08 AM
Hi Team,
I Need to make all the fields an interaction form read only when the state is closed for SOW view.
am trying to do in UI policy, instead of adding all the 12 fields in UI Policy action, i need a script to write in the run script and to achieve.
regards,
Abhilasha G T
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 08:11 AM
create a table.None WRITE ACL and add condition as State [IS NOT] Closed -> Easiest approach
OR
try this and create onload client script and uncheck Global checkbox and add the correct view name so that this script runs only for that view
function onLoad() {
if (g_form.getValue('state') == 'closed') {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 07:13 AM
Hi @Abhilasha G T ,
Always utilize the ServiceNow solution instead of scripting - this is best practice.
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 07:35 AM
Hi Anders,
Thanks for your reply, i need the script to do in UI Policy only,
My Concerns is in future if any new fields added, so no need of creation again UI Policy action for that.
So i need a script to achieve this in UI Policy only.
Regards,
Abhilasha G T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 07:40 AM
Hello @Abhilasha G T,
This would be easily achieved by a WRITE ACL instead.
Could you please go to your Access Control (ACL) check the interaction write ACLs and edit them by adding the condition "State is not closed"?
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 07:52 AM - edited 03-26-2025 08:00 AM
Try below sample client script to make fields read-only on SOW view. You can use the same section the UI policy "Execute if true" script section.
Hope this helps.
Regards,
Siva