
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2021 10:02 PM
Hi Team,
I would like to disable attachment icon(paper clip icon) in both native view as well as in portal page for "report Vaccination" record producer. The record producer is on scoped application. Please help me here to achieve this.
Below is my catalog client script ,
Type : onload
UI type : All
script :
function onLoad() {
document.getElementById("sc_attachment_button").hide();
}
Any input on this would be much appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2021 02:11 AM
Till the you can use this script. It would work in portal and native both
function onLoad() {
//Type appropriate comment here, and begin script below
if(window == null){
var z = this.document.getElementsByClassName("panel-button sp-attachment-add btn btn-link");
z[0].style.display = 'none';
var k = this.document.getElementsByClassName("file-upload-input");
k[0].style.display = 'none';
var aTags = this.document.getElementsByTagName("span");
var searchText = "Add attachments";
var found;
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].textContent == searchText) {
aTags[i].style.display = 'none';
break;
}
}
}
else{
document.getElementById("sc_attachment_button").hide();
}
}
Portal Output:
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
01-18-2021 05:42 AM
No error being noticed in the console.
Thank you Ankur for the inputs.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2021 10:32 AM
Sorry for digging this agian.
The issue fixed onLoad but when I tried to submit form without filling mandatory fields, then the attachment icon is showing again.
Script i Have used is ,
function onLoad() {
// to hide attachment icon in service portal view
if(window == null){
var z = this.document.getElementsByClassName("panel-button sp-attachment-add btn btn-link");
z[0].style.display = 'none';
var k = this.document.getElementsByClassName("file-upload-input");
k[0].style.display = 'none';
var aTags = this.document.getElementsByTagName("span");
var searchText = "Add attachments";
var found;
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].textContent == searchText) {
aTags[i].style.display = 'none';
break;
}
}
}
//to hide attachment icon in native view
else{
document.getElementById("sc_attachment_button").hide();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2021 08:47 PM
Hi,
Didn't get the question
Can you please explain what is not working now
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
02-09-2021 09:17 PM
Initially when I open the record producer it does not show attachment Icon which is fine. But if I try to submit the form without entering mandatory fields, we would get the error message that so and so fields are mandatory right? when the error message appears , the attachment icon becomes visible again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2021 09:36 PM
Hi,
Strange.
Is the attachment mandatory from the portal?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader