Can we hide attachment icon on the portal when the state is closed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2021 11:10 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2021 11:37 AM
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";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2021 11:39 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021 09:57 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2021 10:05 AM
Glad I could be of help 🙂