How to remove / hide the Back Button and Attachment (paperclip) Button from the Top Bar of my Record Producer Preview Item (form)?

georgimavrodiev
Mega Guru

Hello,



My custom application has its record producer (a colleague of mine created it). It serves as a registration form for none users.
If I click on its Preview Item — the form pops up. Its Top Bar contains two buttons: Back & Attachment (paperclip) along with the title of the form: "xxx Request Form".
For references — please check the below screenshot:
CommunityForm.pngMy goal is to remove / hide the two buttons from there and leave only the title.


I reviewed all similar threads (about Attachment button, etc.) in the Community and tried all the scripts proposed there. None of them, but one worked. And it does not hide the Paperclip button, but simply disables it.

The other option which I used was to create a Variable Set and associate it to my record producer and then create an onLoad Catalog Client Script for the Variable Set with the following function:
function onLoad() {
$j('tr.sc_header').hide();
}
I saw this action in one of the threads: Re: Hide Header in Record Producer form.
As I understand — it should remove the whole header bar or in other words: not only the buttons, but also the title of the form. Yet, this also does not work…

I do not have any other ideas or approaches, but to ask for your help and expertise, SNOW fellas.
Could you please assist me with the removing of the two buttons from the Header Bar of my custom Record Producer, but leaving the title of the form?


Best Regards,
Georgi Mavrodiev

IT Consultant
Do IT Wise

You may visit us in our Web Site: www.doitwise.com

1 ACCEPTED SOLUTION

Hi Georgi,



The if condition can be written.


You have the catalog item name in the script tag. Add following



add following lines after this line of code catalogHistory.setHistory('$[HTML:sc_cat_item.name.getDisplayValue()]', catalogHistory.getPageUrl() + '$[AMP]sys_id=$[sysparm_id]');


Replace Something Broken with the name of your catalog item



if("$[HTML:sc_cat_item.name.getDisplayValue()]" == "Something Broken"){


$j("back_button_in_header").hide();


$j("sc_attachment_button").hide();


}      



So this will run only when catalog item matches your name and hide the buttons. for other it won't


i have verified and tested this.



Regards


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

21 REPLIES 21

Hi Georgi,



The if condition can be written.


You have the catalog item name in the script tag. Add following



add following lines after this line of code catalogHistory.setHistory('$[HTML:sc_cat_item.name.getDisplayValue()]', catalogHistory.getPageUrl() + '$[AMP]sys_id=$[sysparm_id]');


Replace Something Broken with the name of your catalog item



if("$[HTML:sc_cat_item.name.getDisplayValue()]" == "Something Broken"){


$j("back_button_in_header").hide();


$j("sc_attachment_button").hide();


}      



So this will run only when catalog item matches your name and hide the buttons. for other it won't


i have verified and tested this.



Regards


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Good Morning Ankur,





Thank you very much for helping me out with the if condition!




I have just modified the script of the UI Page in my DEV instance and can confirm that it works!
If I go to my record producer Preview Item and also to the CMS form, I see the buttons are not presented there.


To ensure that we do not impact any other forms, related to the UI Page - I performed a test by going to Self-Service > Service Catalog -> Hardware -> and then clicked on Developer Laptop (Mac). The Back and Attachment buttons are presented into this form, so I think everything is OK.



Here, I have to say that the lines of the script of the UI Page in my DEV instance are little different than the lines of yours, which you shared above.BlaBla3.png


As you see, I do not have   + '$[AMP]sys_id=$[sysparm_id]' on line 36. I also used '#button_name' instead of "button_name".



Well, with this said I will mark the thread as "Answered".
Thank you very much for your extremely kind and helpful assistance, Ankur! (handshake)




To all interested - if you are dealing with exactly the same task - then locate the UI Page "com.glideapp.servicecatalog_cat_item_view" and perform the above changes of its script code, by replacing "Request Form" with the name of your own catalog item. And always use if condition in order not to impact other items that use the same UI Page.




Best Regards,


Georgi Mavrodiev



IT Consultant
Do IT Wise



You may visit us in our Web Site: www.doitwise.com


Hi Georgi,



Great that it worked. Yes the script might be different somewhat, but as far as your testing goes fine that should not impact anything.


Could you also hit like for the comment. Thanks in advance.



Regards


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi again,





I've actually just found another - better solution by going back to the begging of my tests.


The original syntax was incorrect and thus it did not work on my instance.



Instead of changing the global UI Policy, I went back and continued the original approach - Catalog Client Script.
Once again, I made it to be onLoad and to run against my catalog item.



This time, instead of using $j('tr.sc_header').hide(); or gel("back_button_in_header").style.display = "none"; & gel("sc_attachment_button").style.display = "none"; I used the below syntax:


BlaBla4.png


It works perfectly!




I believe this is the best approach here, taking under consideration the fact that we do not change anything in the Global scope




Best Regards,
Georgi Mavrodiev



IT Consultant
Do IT Wise




You can visit us in our Web Site: www.doitwise.com


Hi Georgi,



This approach was already mentioned by me in my earlier post to use the catalog client script and use onLoad script and hide the buttons.


The approach of changing the ui page is not recommended since it is a change to the out of box script and may be affected during next instance upgrade.



Regards


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader