The CreatorCon Call for Content is officially open! Get started here.

Hide Service Portal 'Submit' button based on Form condition.

Wesley Breshear
Tera Expert

Hello,

Hopefully, this is an easy question.   I am still learning JavaScript and have no experience with AngularJS.   Anyway, I am trying to hide the 'Submit' button on a form within Service Portal.   Basically, the response on a specific question will determine if the user should be filling out a different form or not.   If true, then they are given a widget pop-up window with a hyperlink to the form that should be using.   This appears based on a UI Policy and makes the remaining fields on the form Read Only, however, the user is still able to submit the request.   I haven't been able to find a way to hide or make read only the 'Submit' button in the Service Portal.   I have found how to via CMS but not Service Portal.   There is similar request to hide the button on the Service Portal from but the button is hidden based catalog item and it appears to use AngularJS.   I can't figure out how to modify the code and then hide based on a condition.   I am not even sure if I can hide it with the Widget that I am calling by UI Policy or if I should be using a completely different process/method.   Could you help with the method and code that I should be using?

Request Form:

Request Form.jpg

Widget: (see attached for larger copy)

Widget Notification.jpg

UI Policy:

UI Policy.jpg

Thank you,

-Wesley

1 ACCEPTED SOLUTION

chirag_bagdai
ServiceNow Employee
ServiceNow Employee

Hi Wesley,



There are couple of options which you can try :



  1. Clone OOB "SC Catalog item" widget and add your custom validation for "Submit" button.
  2. Add onSubmit Catalog client script and you can give alert message and using "return false" statement. User will not be able to submit the request.

find_real_file.png


      3. Declare below function in your custom widget (software development tool)


                  find_real_file.png


  and call this function from UI policy whenever you want to hide. Note : you can add another function for show.


View solution in original post

13 REPLIES 13

You may try "angular.element('button[name="submit"]').css('visibility', 'hidden');" instead hide() function.



But this is not suggested way (DOM manipulation), you should clone OOB widget and modify according to your business use case.



Thanks,


Chirag


hey Chirag,

@chirag.bagdai 

I tried the same exact thing, but I got js error 

js_includes_sp.jsx?v=08-06-2020_0931&lp=Mon_Aug_17_11_04_35_PDT_2020&c=19_802:41464 (g_env) [SCRIPT:EXEC] Error while running Client Script "hide show submt button": ReferenceError: hideSubmitBtn is not defined

 

Any ideas?

hey Wesley,

I tried the same exact thing, but I got js error 

js_includes_sp.jsx?v=08-06-2020_0931&lp=Mon_Aug_17_11_04_35_PDT_2020&c=19_802:41464 (g_env) [SCRIPT:EXEC] Error while running Client Script "hide show submt button": ReferenceError: hideSubmitBtn is not defined

 

Any ideas?

Hi SN Emy,

Sorry, missed your request for help.  Were you able to resolve your issue and get it working?

-Wesley