Make field mandatory after submitting (incident)

Snow Tomcal
Tera Expert

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 

 

7 REPLIES 7

jaheerhattiwale
Mega Sage
Mega Sage

@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.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

It makes the field mandatory before submitting.

SuhasPSalunkhe
Kilo Guru

After the g_form.mandatory line, add line return false. I will stop the submission.