- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 04:21 AM
Hi Team,
Can someone help me on how to hide attachments from incident form. I have seen many post related to hiding attachment icon(paper clip). My requirement was to hide the document itself from form based on view. Any help is appreciated.
Regards,
Prets.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 04:41 AM
Hi,
you can create onload client script on incident form
Give the view name you want for which it should be hidden in the view field
1) Uncheck Global
2) Give your view name there
script below:
function onLoad(){
g_form.disableAttachments(); // hides the paper-clip icon
}
Note: Remember they can still add/remove attachments by clicking on Manage Attachments
For hiding the manage attachments section you can update this in onload client script above
Ensure: Isolate Script field is set to false for this client Script; This field is not on form from list you can set it to false; it is true by default
Updated Script:
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.disableAttachments();
if(window == null){
// portal
var names = this.document.getElementsByClassName('sp-attachment-manager ng-isolate-scope');
names[0].style.display = 'none';
// to hide paper-clip icon on portal
var names1 = this.document.getElementsByClassName('pull-right attachment-button ng-scope');
names1[0].style.display = 'none';
}
else{
document.getElementById('header_attachment').style.display = 'none';
}
}
Mark the comment as a correct answer and helpful if this answers your question.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2021 02:37 AM
Can you share screenshot.
For sys_popup view you cannot run any client script or UI policy so you might have to take ACL approach
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2021 04:55 AM
yeah i understand i was just trying to get any other workaround as i dont want to disturb OOB ACLS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2021 06:47 AM
Hi Ankur,
For self-service view name is "ess".
Then then solution will work.
Thanks,
Uday

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 04:41 AM
Hi,
Is it for the backend you are referring to then you can create an onLoad() dom manipulated client script as below that runs on your required (incident) table.
function onLoad() {
document.getElementById('header_attachment').style.display="none";
}
Before:
After:
g_form.disableAttachments(); will hide the paper-clip for your case as you need to hide entire Manage Attachment from header then you will have to go with DOM as above.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 04:56 AM
HOW TO DETECT THE VIEW IN CLIENT SCRIPT AND THEN HIDE ATTACHMENT FILES FROM THE FORM
create a client script and set the following condition
- type = onload
the script as below, I used here setTimeout function sometimes code to hide attachment executes even before attachments get loaded on the form. so we will wait half a second and then hide the attachments files
function onLoad() {
//Type appropriate comment here, and begin script below
var view = getView();
if (view.toLowerCase()=='major incidents'){
g_form.disableAttachments();
setTimeout(function(){
document.getElementById("header_attachment").style.display = "none";
}, 500);
}
}