Restrict submission of request if user selects "No" for a specific variable/question

gnunez
Kilo Guru

Hello all,

We have a form where its required for the user to have a certification completed. I added a Yes/No question ask whether they have completed this certification.

I want to see if there is a way to restrict submission of the request if they select "No" for this specific question. Any advice or know if this is even possible?

*Currently I have an If statement in the workflow, where if they answer "No" it ends the request. This isn't so great because the user would have to input all their information and then realize that nothing was recorded.

Thanks in advance!

-Grace

1 ACCEPTED SOLUTION

vinothkumar
Tera Guru

Hi Grace,



Create an Onsubmit client script to check the value as "Yes" or 'No"



function onSubmit()


{


var trainingcompleted = g_form.getValue('Variable_name');


If(trainingcompleted == 'No')


{


alert("Please complete the certificate training");


return false;


}


}


View solution in original post

4 REPLIES 4

Raghu Loganatha
Kilo Guru

Grace,



You can write an on submission client script saying where:



If(field_name == false)


{


return false;


}


Jaspal Singh
Mega Patron
Mega Patron

Hi Grace,



You can have an Onsubmit client script written to validate each field & its option selected. If any of which has No selected you can use return false; to abort the submission & even an alert can be used to make user aware of the same.



Links: function onSubmit - Client Script Help   Client Scripts - ServiceNow Wiki   would help.


vinothkumar
Tera Guru

Hi Grace,



Create an Onsubmit client script to check the value as "Yes" or 'No"



function onSubmit()


{


var trainingcompleted = g_form.getValue('Variable_name');


If(trainingcompleted == 'No')


{


alert("Please complete the certificate training");


return false;


}


}


Thank you Vinoth, this is what I was looking for!