Can we hide attachment icon on the portal when the state is closed?

Kirthi2
Tera Contributor

I am trying to hide adding attachments to the portal when the ticket state is closed, has anyone implemented this. I have searched the community and see there are solutions for hiding the button completely. 

I would like to do it only in a closed state on catalog tasks and Requested Items. I tried writing an ACL on the attachment table but that doesn't seem to work.

Did anyone have a similar requirement?

 

4 REPLIES 4

Willem
Giga Sage
Giga Sage

Some options:

- The ACL on Attachment table. Since you have tried that, can you share screenshots of that and (if applicable) the code?

- Other option is a (Catalog) Client Script.

For example as Suggested by Mark here:

Create a new Catalog Client Script
Type: onLoad

function onLoad() {
	
	var attachmentButton = top.document.getElementsByTagName('sp-attachment-button');
	attachmentButton[0].parentNode.hidden = true;
	
}

 

- Mike suggested to clone the widget (in that thread the SC Catalog widget). Depending on the type of 'ticket' you might have a different widget. See if you can apply the same principle as discussed here:

Clone SC Catalog Item and add to the page.

On clone widget in client script you will see something like. Make sure to add sys_id of catalog item you want to exclude 

c.showAttachments = function() {
		return !$scope.submitted &&
			!c.data.sc_cat_item.no_attachments &&
			c.data.sc_cat_item.sys_class_name !== "std_change_record_producer";
	};

change it to

c.showAttachments = function() {
        if (c.data.sc_cat_item.sys_id == 'SYS id of catalog item') {
            return false;
        } else {
            return !$scope.submitted &&
                !c.data.sc_cat_item.no_attachments &&
                c.data.sc_cat_item.sys_class_name !== "std_change_record_producer";
        }

 

Willem
Giga Sage
Giga Sage

Video about this topic from a few years ago by Göran Lundqvist might also be of use:

https://www.youtube.com/watch?v=xeh8-OA8UMc&feature=emb_logo

Kirthi2
Tera Contributor

Thank you Willem, for your response. I was able to use the code and the YouTube video helped me understand how I can modify to meet the requirement.

After I complete the entire requirement. I will post the my notes here too.

 

Glad I could be of help 🙂