Block submitting form after choosing specific form option

AdamUMC
Giga Guru

Hi,

I have a probably simple question: Is it possible to disable the possibility to sent/submit forms, after choosing a specific form option in the form itself?

Thanks!

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

You can write a onsubmit script which will have the logic that if the chosen option is the one we just return false and the user is not able to submit the form.

 

The script will look something like below:-

 

function onSubmit(){
   var mandatoryVar = g_form.getValue('fieldname');
   if (mandatoryVar =="optionwewanttostopfor"){
      alert("You cannot submit for this option");
   return false; }
}

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0622896

 

Please mark my answer as correct based on Impact. 

View solution in original post

5 REPLIES 5

Elijah Aromola
Mega Sage

You can create an onSubmit client script to check for that value/selection and then return false if that condition is met. This prevents the form from submitting. You can also use a business rule on the server side with whatever conditions and in the actions tab select "Abort action".

Mike_R
Kilo Patron
Kilo Patron

Yes, you can create an onSubmit client script

Example:

function onSubmit() {


    if (g_form.getValue('field_or_variable') == 'whatever you are checking for') {
       return false;
    }
	else{
		return true;
	}


}

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

You can write a onsubmit script which will have the logic that if the chosen option is the one we just return false and the user is not able to submit the form.

 

The script will look something like below:-

 

function onSubmit(){
   var mandatoryVar = g_form.getValue('fieldname');
   if (mandatoryVar =="optionwewanttostopfor"){
      alert("You cannot submit for this option");
   return false; }
}

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0622896

 

Please mark my answer as correct based on Impact. 

Alp Utku
Mega Sage

As others explained already, you can use OnSubmit catalog client script but as another option, you can use user criteria to hide the catalog Item for a specific location

 

https://docs.servicenow.com/en-US/bundle/tokyo-servicenow-platform/page/product/service-catalog-mana... 

 

https://docs.servicenow.com/bundle/tokyo-servicenow-platform/page/product/service-catalog-management...