Prevent form submission

Pierre Midro
Tera Contributor

On a form in the service portal , I would like to block the "submit" button if the User selects the "Using Politemail" checkbox,
See screenshot
Your help will be much appreciated.

 

find_real_file.png

1 ACCEPTED SOLUTION

Aman Singh_
Kilo Sage

Hi

 

Create a ONSubmit client script.

and check if selection is Using Politemail and use

return false

to prevent form submission.

Please mark Correct/helpful???? if applicable, thanks!!

Aman

 

View solution in original post

8 REPLIES 8

Aman Singh_
Kilo Sage

Hi

 

Create a ONSubmit client script.

and check if selection is Using Politemail and use

return false

to prevent form submission.

Please mark Correct/helpful???? if applicable, thanks!!

Aman

 

Ashish Narwal
Kilo Sage

Hi,

If this is a submit button that would be seen from a Record Producer or Catalog Item, you could disable the Submit button using an onSubmit Catalog Client Script in the Record Producer/Catalog Item.

Ensure that the onSubmit Catalog Client Script has a UI Type of "Both or only Service Portal", add in your conditional criteria for when you would want to disable the Submit button, and end that conditional criteria with "return false;" For instance:

function onSubmit() {

 if (g_form.getValue('subcategory') == 'DisableSubmit') {

             var message = '';

              message = message + 'Submit is disabled for the specific subcategory' + '\n' + '\n';

              alert(message);

              return false;

      }

}

 

Mark helpful/correct if that solves your issue.

Thanks,

Ashish

Ankur Bawiskar
Tera Patron
Tera Patron

@Pierre Midro 

You cannot disable that Submit button unless you play around using HTML DOM.

That is not recommended.

Instead as per comment from Aman you can create onSubmit Catalog Client Script and stop the form submission.

If your business still requires to show/hide based on the change of the variable then refer below link where I have shared approach

Remove/disable/hide record producer Submit button.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Pierre Midro 

Did you accidentally marked other response as correct?

the response marked as correct doesn't mention about disabling the submit button.

Please mark appropriate response as correct so that it helps future members.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader