- 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
04-05-2022 04:58 AM
Hi
Can you please explain in detail where to update the cloned widget details ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2022 06:41 AM
Sorry if this is too basic, but I'll try to go through everything. I'm amending my previous response to make it make it work in broader situations and follow best practice:
- Add a system property by navigating to "sys_properties.list"
- Click the 'New' button
- Add a name for the property and a description. I used "exclude_attachments_on_convo_page" for the system property Name in the code below.
- Set the 'Type' to "String"
- Enter in the 'Value' field the sys_id(s) of the catalog item(s) that need to be excluded. If multiple catalog items need to be excluded, separate the sys_ids of the catalog items with commas
- Save the new property
- Navigate to Service Portal > Widgets
- Query the list of widgets for 'ID' contains "widget-ticket-conversation"
- Open the resulting record (it should be read-only)
- Click the 'Clone Widget' button. A copy of the widget will be created and should be editable
- Give the cloned copy its own Name and ID
- In the 'Server script' field, scroll to the bottom where you will find the function "userCanAttach" (for me (Rome), that function starts on line 131)
- Add the code below between the first "return false" and the large comment below it (for me, that would be line 134)
- Edit the code snippet so that "exclude_attachments_on_convo_page" is the name of the system property from above.
- Save the cloned widget.
- Navigate to Service Portal > Service Portal Configuration
- Click the Page Editor box
- Search for the page that contains the widget you need to edit. This is probably called "Ticket Form" (or "ticket")
- Locate the tree structure on that page and find the box that says "Ticket Conversations". Click the box just to the left of that (probably says "Conversations").
- Scroll to the bottom and locate the Widget field.
- Change that field from "Ticket Conversations" to whatever you named the cloned widget in the previous steps.
- Save the widget instance.
- Test, test test!
Code for step 13:
//EXCLUDE A CERTAIN CATALOG ITEM
if (originalRecord.sys_class_name == 'sc_req_item') {
var catItems = gs.getProperty('exclude_attachments_on_convo_page');
if (catItems.toString().indexOf(originalRecord.cat_item.toString()) > -1) {
return false;
}
}
//END NEW CODE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2022 08:10 AM
We have a requirement to show the comment box of approval record
and attachment of the doc which is already attached to be made vissible on the portal side of that particular approval .
Can you please help how to attain this requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2022 11:57 AM
That sounds like it deserves its own Community posting. I would recommend creating a new post to see if anyone can assist.