How to write an “On Load” client script on any INC table to make twp fields mandatory ?

Rohit Kumar5
Kilo Contributor

How to write an “On Load” client script on any INC table to make twp fields mandatory ?

1 ACCEPTED SOLUTION

Sumanth16
Kilo Patron

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.

 

find_real_file.png

 (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 

 

find_real_file.png

find_real_file.png

 

 

 

 

 

Please mark as helpful (or) correct if it fixes your issue.

 

Thanks,

Sumanth

View solution in original post

10 REPLIES 10

Allen Andreas
Administrator
Administrator

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:

https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_GlideFormSetMandatory_String_Boolea...

Please mark reply as Helpful/Correct, if applicable. Thanks!

 

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

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!

Sumanth16
Kilo Patron

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.

 

find_real_file.png

 (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 

 

find_real_file.png

find_real_file.png

 

 

 

 

 

Please mark as helpful (or) correct if it fixes your issue.

 

Thanks,

Sumanth

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader