Disable the submit button on record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2017 07:27 AM
I am trying to disable the submit button on a record producer based on the answer of a variable in a catalog client script.
However, when you change this variable back to "--None--" the button still shows as disabled. When the variable is "--None--" the button show still show as enabled.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'no') {
alert('Test.');
document.getElementById("submit_button").disabled=true;
}
else {
document.getElementById("submit_button").disabled=false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2017 07:38 AM
Hi Josh Brostoff
Please Refer the below link .Hope this might be helpful.
Hid submit button on record producer
Regards,
Ajay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2017 07:52 AM
Hi Josh Brostoff,
You can try with the below code. Its working for me
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == null || newValue == '') {
//alert('Test.1');
document.getElementById("submit_button").disabled=true;
}
else {
//alert('Test.2');
document.getElementById("submit_button").disabled=false;
}
}
Regards,
Sagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2017 07:57 AM
I'm going to be blunt - don't do the DOM manipulation.
One message that keeps coming up from older customers is "We have customized the ***** out of this and now we just want to start over from OOB."
That's expensive and unnecessary if you stick with the best practices. Back in 200x, we didn't know any better and people did risky things like DOM manipulation in their client scripts. Now we know better and can prevent it. Don't be the cause of an organization needing to spend lots of money down the road because customizations were required. If the system doesn't do what you need it to and you absolutely cannot find a workaround, put in an enhancement request. Tell the party making the requirement that this one cannot be fulfilled yet and you'll continue to look in to it in the future. Don't force a solution that carries a lot of risk.
(End rant.)
Enhancement requests: Tell us how you would improve the ServiceNow product

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2017 08:05 AM
I just have a feeling to convert the rant into a knowledge article and publish it internally !

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2017 08:04 AM
This answer does not provide you the best user experience but it will work without any unnecessary DOM magic.
Since you are working on a record producer, make use of the power of record producer script. You can access the values of the variable as producer.variablename. Now the script to make this work will be very simple.
if(producer.variablename=='no')
{
current.setAbortAction(true);
gs.addErrorMessage('No ! You won't make it pass me !!!'); // change this
}