onload client is not working for all the section
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2025 05:13 AM
We have dot walk fields on the form, we are using same dot walk fields in multiple sections, We have written a onload client script to hide them based on a condition, but it is working only on the first section and not working for the remaining sections. Can anyone help me on this how to hide on other sections also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2025 05:22 AM
Replace your client script with a ui policy.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2025 05:24 AM
Hi @Nagasri
Agree, with @Mark Manders instead of CS, use the UI Policy that will work on all.
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-07-2025 11:47 PM
Hello @Nagasri
- This issue occurs because dot-walked fields can appear multiple times on a form, but g_form.setDisplay() only hides the first instance.
- ServiceNow’s g_form methods operate only on the first occurrence of a field, while fields appearing in multiple sections generate duplicate HTML elements with the same name.
- To ensure all instances of the field are hidden, UI Policies are a better approach, as they apply to all occurrences of a field across different sections of the form.
To demonstrate the same:
- When using a client script to make a field mandatory, it applies only to the first occurrence on the form.
- When using a UI Policy to make a field mandatory, it applies to every occurrence on the form.
This makes UI Policies a more effective solution.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar