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

Tudor
Tera Guru
Hi, You can disable the submit button manipulating the DOM, but in won't work in the portal. My suggestion is to keep the onSubmit CCS. Tudor

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi John,

It's not possible to "disable" a submit button but it is possible to "hide" it.

Not sure if the content of the following pages are still valid.

https://community.servicenow.com/community?id=community_question&sys_id=5a10009fdb2ea810fb4ae15b8a96...

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

Hi Hitoshi,

How can I hide this submit button from now mobile app also. Can you please give me the solution for this.