I have created an onSubmit cat. Client Script to show an alert if a field is not filled by the user

deepakmaury
Tera Contributor

I have created an onSubmit  catalog Client Script to show an alert if a field is not filled by the user. However, when I make that field mandatory from the Variable settings, the alert does not appear. I also tried using a  catalog Client Script and a  catalog UI Policy, but the alert is still not working. What could be the reason, and how can I fix this?

6 REPLIES 6

lpruit2
Mega Sage

Greetings @deepakmaury. If you make the field mandatory, what is the value of also having an onSubmit Catalog Client Script? The mandatory variable setting/check may be taking place before the actual "Submit" action occurs. 

Aditya_hublikar
Mega Sage

Hello @deepakmaury ,

 

If you make variable mandatory from variable settings then your written only alert without checking variable has value or not then it will not show alert msg , please create catalog client script onSubmit() as shown in below and disable that variable setting mandatory option.

 
 

12.PNG

 

This above screenshot code will stop submission and show alert.

 

 

If this helps you then mark it as helpful and accept as solution.

Regards,

Aditya

yashkamde
Mega Sage

Hello @deepakmaury ,

 

I would recommend avoid mixing mandatory flags with custom submit alerts. Mandatory flags are designed to stop submission automatically. If you need a tailored message, handle it entirely in script logic without the mandatory flag as given by @Aditya_hublikar .
If you just want enforcement, rely on the platform's built‑in mandatory behavior it's more consistent and user‑friendly.

If my response helped mark as helpful and accept the solution.

Its_Azar
Kilo Sage

Hi there @deepakmaury 

But why? you do wither one, why both?  

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.