Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Disable submit button on service portal

asit2
Kilo Expert

Hi Friends,

I want to hide or disable a button on a portal page depending on some data which may be access by Glide Ajax.

How can I achieve the same.

Please help.

3 REPLIES 3

melosborne
Mega Expert

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", 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;


      }


}



I hope that this helps,



- Mel


Inactive_Us1474
Giga Guru

you can add the condition accordingly for hiding/showing in condition field of the button/ui action.


ANANTHULA NAVEE
Tera Contributor

function onSubmit() {

 

      if (g_form.getValue('category name') == 'name of the choice')

            {

 

              g_form.addErrormessage("Your Selected choice is Disabled");

              return false;

       }

}