Make field mandatory after submitting (incident)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2022 01:41 AM
Hi All,
I have a field on the incident record that I want to make mandatory on form submitting.
I created a client script (onSubmit):
function onSubmit(){
g_form.setMandatory('field_name', true);
}
when I'm submitting it's turning to mandatory but after a few seconds the red asterisk disappears.
Does anyone know how to fix this?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2022 02:56 AM
@Snow Tomcal Update the script as below:
function onSubmit(){
if(g_form.getValue('field_name') == ''){
g_form.setMandatory('field_name', true);
return false;
}
}
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2022 04:37 AM
It makes the field mandatory before submitting.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2022 07:10 AM
After the g_form.mandatory line, add line return false. I will stop the submission.