
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 08:24 AM
Hello. I read the post here but that solution is not working for me.
When my code runs, I get the "this.jQuery is defined" alert message, but still the button is not hidden.
Thoughts on what might be going wrong here? Thank you.
I want to do this because if our users answer certain questions the wrong way on a Catalog Item, we don't want them to even be able to submit it.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2024 06:10 AM
I was able to get this working finally, using a different this.jQuery() query:
function onCondition() {
if (this.jQuery){
//alert("1");
//this.jQuery("btn-primary").hide(); //Did NOT work for me. I have no elements of type "btn-primary".
//this.jQuery("#btn-primary").hide(); //Did NOT work for me. I have no elements with id "btn-primary".
//this.jQuery(".btn-primary").hide(); //Any element with class == .btn-primary. This did work for me.
this.jQuery("button[name='submit']").hide(); //Any button element where 'name' = 'submit'. Works also.
//alert("2");
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 09:37 AM
Rather than trying to hide the button which could lead to a poor UX as the user may feel the form is broken and raise an incident, you could use an onSubmit catalog client script to abort the submit process and display a helpful message explaining WHY they're not yet allowed to submit the form. You also avoid problematic DOM manipulation which could break on upgrading the instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 10:28 AM
Actually, I agree with you, @Kieran Anson but I would still like an answer to this specific question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 10:50 AM
Add the 'isolate script' field to your form and set it false. If you're in a scoped app, you'll need to enable script de-isolation following https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0551586

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 11:56 AM
I did that already. That is Tag (1) in my screenshot above.