Hiding "Save as Draft" Button in Catalog Item

karolismick
Tera Contributor

Hi ServiceNow Community,

I am encountering an issue when trying to hide the "Save as Draft" button in a catalog item on the Service Portal, even after clicking Hide 'Save as draft' it is visible. Despite applying a script to hide the button, it remains visible.

Despite applying a script to hide the button, it remains visible.

Here is the script I used:

function onLoad() {
console.log("onLoad function executed");
hideSaveAsDraftButton();
}

function hideSaveAsDraftButton() {
console.log("hideSaveAsDraftButton function executed");
var saveDraftButton = document.querySelector('button.btn.btn-default.sc-btn.form-control.text-overflow-ellipsis[title="save as draft"]');
if (saveDraftButton) {
console.log("Save as Draft button found, hiding it.");
saveDraftButton.style.display = 'none';

I suspect it might be an issue with a new version of ServiceNow or perhaps I am missing something in my approach. Has anyone else faced this issue or can anyone suggest a solution to hide the "Save as Draft" button effectively?

Thank you for your help!

Regards,

Karolis

13 REPLIES 13

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Not sure why you are using a Client Script, that should really NOT be necessary. You should be able to hide Save as draft:

- On Catalog Item level, its a checkbox

- On whole portal level, deactivating it for all Catalog Items at once

 

Question: are you perhaps using a cloned and edited older version of the widget? And might therefor the Hide save as draft not be working? If so, shouldn't you be just updating the widget?

 

Or are you net aware of how to hide the Save as draft out-of-the-box?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron

How to hide Save as draft is described in this article:

- 2024-03-08 - Article - Save Catalog Items as draft

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

karolismick
Tera Contributor

Hi Mark,

Thank you for your fast response!

I have tried to hide the "Save as Draft" button by simply checking the checkbox on the Catalog Item level, but for some reason, it does not work. The button remains visible on the portal.

Regarding the widget, it is not out of date. We are using the latest version, so I don't believe that's the issue.

Any further suggestions or insights on why the checkbox method isn't working would be greatly appreciated.

I will check out your suggested article.

Kind regards,

Karolis

Out of the box this works perfectly fine. So something on your instance needs to be different than. Usually, its the widget, a common thing I see at the majority of customers.

 

Don't immediately go for a strange workaround and introducing more technical depth and which eats up a lot of your time developing anyway. Search for the actual cause.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn