- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 06:02 AM
Hello,
I've a requirement to remove the Attachment paper clip for the catalog items after submitting the item i.e, on the submit page of the Portal, for which we've opted 'Hide Attachment' as 'True' in the Portal Settings. I've tried multiple ways by modifying the 'Ticket Attachments' widget on the Service Portal. But nothing worked out.
Please help me with the procedure.
Thanks in advance
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2022 02:56 AM
Ok then modify to check the catalog item here,
1. create a property with the sysid of the catalog items.
2. check if the ritm is from the catalog item.
3. block/allow the attachment
this should be added above the data.canAttach line.
var currentRecord = $sp.getRecord(); // get the current record
var catitemrecord = currentRecord.cat_item; // check the catalog item
// the property should contain the sysid of the catalog item
var restricAttachment = (catitemrecord.indexOf(gs.getProperty('name of prop')) > -1)
// add the line "&& !restricAttachment" this will not allow attachment for the sysid mentioned in the property
data.canAttach = gs.hasRole(gs.getProperty("glide.attachment.role")) && GlideTableDescriptor.get(data.table).getED().getAttribute("no_attachment") != "true" && !restricAttachment;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2022 04:15 AM
Okay, don't clone the widget. What you do instead is this:
You create a new widget, and in that widget you in the server script define the attachments widget, so you can do it like this:
Server script:
data.attachmentWidget = $sp.getWidget("widget-ticket-attachments"); //This is your ootb widget - no reason to clone it!!
data.hideAttachments = checkTicket(); //This is whether or not to show the attachment widget
//You then need a function to check the ticket and what item it belongs to.
//Example
function checkTicket(){
var id = $sp.getParameter("sys_id");
var table = $sp.getParameter("table");
if(table == 'sc_req_item'){
var reqitm = new GlideRecord('sc_req_item');
reqitm.get(id);
var item = reqitm.getValue('cat_item');
if(item == 'sys_id_of_item1' || item == 'sys_id_of_item2') { //You could properly have something on the item it self to check this value, or have it in a property instead of hardcoding sys_ids.
return true;
} else {
return false;
]
} else {
return false;
}
}
HTML:
<div ng-if="!data.hideAttachments">
<sp-widget widget="data.attachmentWidget"></sp-widget>
</div>
Then you simply replace the ootb widget on the ticket page with your newly created widget, without changing functionalities and miss future upgrades.
Best regards,
Sebastian Laursen

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 06:24 AM
can you try this,
press control + right-click, open the widget editor, if OOB widget, clone it and amend this line and add this widget to the widget instance on that page.
from
data.canAttach = gs.hasRole(gs.getProperty("glide.attachment.role")) && GlideTableDescriptor.get(data.table).getED().getAttribute("no_attachment") != "true";
to
data.canAttach = gs.hasRole(gs.getProperty("glide.attachment.role")) && GlideTableDescriptor.get(data.table).getED().getAttribute("no_attachment") != "true" && gs.hasRole('admin');
this will allow only the admin to attach it. Also this stop attachments from the pages where the widget is used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2022 02:14 AM
Hello Murali,
The requirement is not only for Enduser and also, it shouldn't be visible particularly for 2 catalog items for the rest of them all the functionality should be as is.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2022 02:56 AM
Ok then modify to check the catalog item here,
1. create a property with the sysid of the catalog items.
2. check if the ritm is from the catalog item.
3. block/allow the attachment
this should be added above the data.canAttach line.
var currentRecord = $sp.getRecord(); // get the current record
var catitemrecord = currentRecord.cat_item; // check the catalog item
// the property should contain the sysid of the catalog item
var restricAttachment = (catitemrecord.indexOf(gs.getProperty('name of prop')) > -1)
// add the line "&& !restricAttachment" this will not allow attachment for the sysid mentioned in the property
data.canAttach = gs.hasRole(gs.getProperty("glide.attachment.role")) && GlideTableDescriptor.get(data.table).getED().getAttribute("no_attachment") != "true" && !restricAttachment;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2022 07:56 AM
Hi Murali,
It worked. Thanks for the code.