Hide Submit button on Portal dynamically

Austen Harriso1
Tera Contributor

How can I hide the submit button on the Service Portal dynamically when a selected variable has a particular choice value? Looking to prevent the user from submitting the form if they answer a question with a choice that indicates they should not submit the request.

3 REPLIES 3

Thanks Alex! But DOM manipulation doesn't work well with the new portal. I found that guru link and implemented the suggested script but it doesn't work with the Service Portal. As a workaround, I've included an onSubmit script to prevent the user from submitting, but I'd really like to know how to hide elements on the Service Portal without breaking into the widget code.


Dale Hynes
Kilo Sage

I've figured out a method that works in Service Portal. This method reads a value from a field on the Catalog Item (server-side) so would have to be modified to use a Ajax call form the Client Script part of the widget.



Use the 'No order now' field on the Catalog Item (boolean: 'no_order_now')


Clone the 'SC Catalog Item' widget, I named my new one 'SC Catalog Item - Submit Check'


In the new widget, add the following:



** Server Script under line 42


//


var gr = new GlideRecord('sc_cat_item');


gr.get(data.sys_id);


data.no_order_now = gr.getValue("no_order_now");


//



** HTML template, insert under Line 26 (aka create new Line 27)


<div ng-if="data.no_order_now != '1'" class="b-t wrapper-md">



Close this with a new </div> inserted under LIne 44 (as new Line 45) which is immediately after the Add Attachments code.




So the value of the field is read and if not '1' then do not enter the HTML for the Submit, Price, Quantity, Attachment footer.


Set 1 or more Items to No order now = true, edit your portal page to add your new widget underneath the out-of-box SC Catalog Item widget.


Test it against one of your modified items.