Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to hide the attachments showing on top of item and task forms

dp11
Tera Guru

Hi,

I have implemented a 'defined relationship ' to show all attachments in a requested item and catalog task form under tabbed

sections. I would like to hide the list of attachments that shows up at the top of the form by default. Any one knows how to

do this?

Thanks,

Debashree  

1 ACCEPTED SOLUTION

Artemis15
Kilo Guru

Hi Debashree,



You can hide attachment link by this:



$$('img[title="Attachments..."]')[0].up().up().down().hide();



For hiding attachment section, You need to write again custom javscritp code.



document.getElementById('header_attachment').style.display="none";



As well as you have to hide attachment section line


for this :


document.getElementById('header_attachment_line').style.display="none";



Put these 2 lines on any onload client script.



-


Cheers,


Akash Rajput


View solution in original post

17 REPLIES 17

Hello Akash,



The UI formatter doesn't have any code in it. It is created from a ui macro. Basically, I wanted a button on the form, under a specific section, so I created a ui macro and gave it to a ui formatter. I want this ui formatter to be visible only if user has a specific role. I am sorry, can't give access to my dev instance.


Hi Keerthana,



You can hide your button on the behalf of id/class or any selectors. Try it


Thank you so much Akash. I used id and it worked.


Hi Keerthana,



Could you please share the code? I also have a similar requirement.



Thanks.


Hi Urmilla,


Write a client script (onLoad) type for the table where the attachments need to be hidden. Add the following in the script:



g_form.disableAttachments();