Is it possible to disable the Submit button on catalog items?

johnfeist
Mega Sage
Mega Sage

I have a catalog item that opens with one mandatory variable, a choice list, visible.  Depending on which option is taken, other variables are exposed.  If certain of the choices on the initial variable are taken we don't want the requestor to be able to submit the request.

The initial variable is mandatory, but since a choice has been taken that condition is met.  Is there any way other than trapping via an On Submit CCS that I can prevent the user from submitting the request, e.g. dsiable the submit button?

Thanks for any suggestions.

:{)

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster
1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi again,

Tested it in my instance. I've created a field of type "Yes/No" to trigger to display or hide the "Submit" button

onChange() script on variable "error_selection" that I'm using to toggle to display or hide.

I've disabled "Isolate script" an set UI Type to "All".

function onChange(control, oldValue, newValue, isLoading) {
   if (newValue == '') {
      return;
   }
    if (newValue == 'Yes') { // hide submit button
        if (window == null) { // service portal
            var z = this.document.getElementsByClassName("btn btn-primary btn-block ng-binding ng-scope");
            z[0].style.display = 'none';
        } else { // ui platform
            document.getElementById("oi_order_now_button").style.display = 'none';
        }
    } else { // display submit button
        if (window == null) { // service portal
            var y = this.document.getElementsByClassName("btn btn-primary btn-block ng-binding ng-scope");
            y[0].style.display = 'initial';
        } else { // ui platform
            document.getElementById("oi_order_now_button").style.display = 'initial';
        }
    }
   
}

Execution results

1. Portal

Case display submit button

find_real_file.png

Case hide submit button

find_real_file.png

2. UI16

Case display submit button (using the default "Order Now" button)

find_real_file.png

Case hide submit button

find_real_file.png

View solution in original post

8 REPLIES 8

Arturo
Tera Contributor
Try this approach, simple but effective: https://community.servicenow.com/community?id=community_question&sys_id=c9133c6adbe9f090b1b102d5ca96192f

Allen Andreas
Administrator
Administrator

Hi,

This gets asked from time to time and honestly, believe it or not, "hiding" the submit button can actually cause more problems. Like in the solution you've marked as correct, the box where the submit button would be is still visible, so then users start to think the UI is broken or something is wrong. Because in other catalog items the button is there, they're used to it, and prior to a certain selection, they saw it there, then it randomly disappeared.

It's better to guide the user and keep them informed versus breaking the UI in DOM manipulation, etc. and causing confusion, in my opinion.

Instead, you can simply provide feedback to the user when they go to submit that due to 'x' they can't submit. Something along those lines.  So an onSubmit client script with field validation and then returning false.

In any case, if what you've marked as Correct for you is fine and working for you, then by all means go for it! 🙂 I just wanted to provide an alternate perspective as it's really not ideal to manipulate the DOM.

Thanks!

-Allen


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Stepan Kravciv
Tera Contributor

You can use g_scratchpad to pass information to onSubmit catalog client script

sonalihanda
Tera Contributor

 

We can also hide the Submit button on a catalog item without using a script by following these steps:
Go to the Service Catalog table (sc_catalog), search for the specific Catalog Item (sc_cat_item)

where changes are needed, then in the related list, modify the “No order now” field in the personalized list.

Please click Helpful if you find this information useful.