business rule which checks all the fields mandatory are empty or not

Jitu Kumar
Tera Contributor

I want to write a business rule where the condition is:

Status is progress

In the script part I want to check whether the mandatory fields are empty or not. If empty it should show popup that "Please fill the mandatory fields" then update the mandatory fields manually and once the fields are filled manually after updating the status should change to Review.

Can anyone help me with the scripting part?

1 ACCEPTED SOLUTION

Voona Rohila
Kilo Patron
Kilo Patron

You can write OnSubmit client script and make mandatory or check if values are filled or not if state is progress.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

8 REPLIES 8

Voona Rohila
Kilo Patron
Kilo Patron

You can write OnSubmit client script and make mandatory or check if values are filled or not if state is progress.


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

palanikumar
Mega Sage

Hi,

Your question is not clear. If you set a field mandatory then user cant submit the form. The BR will get executed only if the form is submitted.

For your requirement I suggest UI Policy. ServiceNow has a default way to highlight whether a field is mandatory or not. Do you want to use custom script?

Thank you,

Palani

Thank you,
Palani

Actually I have done it through client scripts. Anyhow thank you so much. 

Abdul Basha Sye
Kilo Guru

Hi Jitu,

Hope you are doing well !

I would suggest to write On submit client script instead of business rule as Business rules are used for server scripting.

In on submit client script check mandatory fields is empty with help of g_form.getValue("field_database_name) == "" and set state value to Review with help of g_form.setValue("field_database_name", "database_value_of_review_state"). ServiceNow has out of box message for a field is mandatory or not.

Thanks & Regards,

Abdul

Please mark my response as correct & helpful so that this thread can be closed and others can be benefited by this.