I have created an onSubmit cat. Client Script to show an alert if a field is not filled by the user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2026 10:55 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2026 01:39 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2026 03:23 AM
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2026 04:20 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2026 11:16 AM
Hi there @deepakmaury
But why? you do wither one, why both?
Kind Regards,
Azar
Serivenow Rising Star ⭐
Developer @ KPMG.
