Conditionally mandatory fields

johnsgp
Mega Expert

I have some fields of a table which I want to be mandatory under certain conditions only.

To do this on a form, I can write a client script which does g_form.setMandatory or I can write a UI Policy.

What about if I want to do this on a list?   What is the best practice for making fields conditionally mandatory so that list edits will fail if the conditionally-mandatory fields are blank?

Concrete example: I want the Department field to be mandatory if the Company field is filled in on the Users table.   If Company is blank, then Department can be blank too.   If I set this up on the form, the policy can be avoided by editing using the list editor instead of the form.

1 ACCEPTED SOLUTION

You can try adding gs.isInteractive condition in your script and that should do the job for you.


GlideSystem - ServiceNow Wiki


View solution in original post

8 REPLIES 8

johnsgp
Mega Expert

I will try that but I'm aware business rules would affect more than just the list editor.   I agree this does seem to be the most robust solution but is there anything that will work on lists but not, say, import sets or other background work?


You can try adding gs.isInteractive condition in your script and that should do the job for you.


GlideSystem - ServiceNow Wiki


Yes, that would do it - thanks!