- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 11:18 AM
How to write an “On Load” client script on any INC table to make twp fields mandatory ?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 04:54 PM
Hi Rohit,
Please go to client scripts under system definition. And click on the "New" button on the list view. Enter the name and select table as Incident and select type is onload and UI type is all. And replace field names in the below script.
(or)
You can do it through the UI policy also.
Please go to system definition -> Ui policies and selects new from list view
Select the table "incident" and filter condition if applicable.
And create UI policy actions related list click on new and select those fields and make mandatory as true
Please mark as helpful (or) correct if it fixes your issue.
Thanks,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 04:47 PM
Hi,
I'm not sure what you mean by any Incident table, but you can use UI Policy for this to set those fields as mandatory. Client script is really recommended ONLY IF the UI Policy can't work for you.
However, here is the documentation on using setMandatory that you can use in client script:
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2020 05:18 AM
I'm glad you found the correct answer. I know it's easier when someone gives exact instructions with sample code, but my reply was to help educate you on available resources...so you can refer to documentation and learn yourself.
You can also see from the numerous replies you got, that everyone is basically saying the same thing I did, haha.
Take care!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 04:54 PM
Hi Rohit,
Please go to client scripts under system definition. And click on the "New" button on the list view. Enter the name and select table as Incident and select type is onload and UI type is all. And replace field names in the below script.
(or)
You can do it through the UI policy also.
Please go to system definition -> Ui policies and selects new from list view
Select the table "incident" and filter condition if applicable.
And create UI policy actions related list click on new and select those fields and make mandatory as true
Please mark as helpful (or) correct if it fixes your issue.
Thanks,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 07:12 PM
Hi Rohith,
If you want those 2 fields as mandatory always on form load you can use UI policy and UI Policy Action for the same.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader