- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 06:55 AM
Hi,
I want to hide Attachment Icon which is present on Ticket Conversation widget for one particular catalog item. Can anyone suggest me on this. Thank You!
Regards,
Ganesh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:42 AM
Once you have cloned the widget, you would update the 'userCanAttach' function in the 'Server script' field. Something like this:
function userCanAttach(originalRecord) {
if (!gs.hasRole(gs.getProperty("glide.attachment.role")))
return false;
//EXCLUDE A CERTAIN CATALOG ITEM
if (originalRecord.sys_class_name == 'sc_req_item' && originalRecord.cat_item == '[the sys_id of your cat item]') {
return false;
}
//END NEW CODE
// To check whether user can upload attachments, need to check "no_attachment" table
// attribute of the target record (e.g., incident vs. task), so fetch it if we need to.
// GlideRecordScriptUtil.getRealRecord is not available to scoped apps, so can't use it.
var targetRecordForAttributes = originalRecord;
if (originalRecord.getRecordClassName() != originalRecord.getTableName()) {
targetRecordForAttributes = new GlideRecord(originalRecord.getRecordClassName());
targetRecordForAttributes.get(originalRecord.getUniqueValue());
}
return targetRecordForAttributes.getAttribute("no_attachment") != "true";
}
You would then need to update the 'ticket' page to use your cloned copy of the 'ticket_conversation' widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:16 AM
You would need to clone the ticket conversation widget and then adjust the widget's Server Script's "userCanAttach" function. You have access to a GlideRecord of the currently-displayed task, so the catalog item value should be available to you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:30 AM
Hello
Thank you for your reply.
I just want to hide the attachment icon for one particular catalog item. Could you please help by providing more information to achieve this.
Regards,
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:42 AM
Once you have cloned the widget, you would update the 'userCanAttach' function in the 'Server script' field. Something like this:
function userCanAttach(originalRecord) {
if (!gs.hasRole(gs.getProperty("glide.attachment.role")))
return false;
//EXCLUDE A CERTAIN CATALOG ITEM
if (originalRecord.sys_class_name == 'sc_req_item' && originalRecord.cat_item == '[the sys_id of your cat item]') {
return false;
}
//END NEW CODE
// To check whether user can upload attachments, need to check "no_attachment" table
// attribute of the target record (e.g., incident vs. task), so fetch it if we need to.
// GlideRecordScriptUtil.getRealRecord is not available to scoped apps, so can't use it.
var targetRecordForAttributes = originalRecord;
if (originalRecord.getRecordClassName() != originalRecord.getTableName()) {
targetRecordForAttributes = new GlideRecord(originalRecord.getRecordClassName());
targetRecordForAttributes.get(originalRecord.getUniqueValue());
}
return targetRecordForAttributes.getAttribute("no_attachment") != "true";
}
You would then need to update the 'ticket' page to use your cloned copy of the 'ticket_conversation' widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2022 07:47 AM
Hello
Thank you so much for your help.
Regards,
Ganesh