How to disable Attachment document in incident form

Preethi5
Tera Expert

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.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

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

find_real_file.png

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';
		}

}

find_real_file.png

Mark the comment as a correct answer and helpful if this answers your question.
Regards
Ankur

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

View solution in original post

10 REPLIES 10

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

We dont stored this information from where it is bookmarked.


What you can do it in your widget code you can set the window name to portal or use tag field to portal so that you know that this is added by portal.

Thanks,
Ashutosh

Ankur Bawiskar
Tera Patron
Tera Patron

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

find_real_file.png

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';
		}

}

find_real_file.png

Mark the comment as a correct answer and helpful if this answers your question.
Regards
Ankur

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

Thanks alot for your reply.

Its working fine now.

Regards,

Prets.

Community Alums
Not applicable

Hi Ankur,

 

How to hide attachments on sys_popup view .I am able to hide it on form but users are still able to see the attachments from sys_popup view clicking on i icon on the list view

 

Please help

 

Thanks,

Priyanka