Ticket Conversation Widget Modification!!!

Community Alums
Not applicable

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 

1 ACCEPTED SOLUTION

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. 

View solution in original post

8 REPLIES 8

Hi @Tim Deniston ,

Can you please explain in detail where to update the cloned widget details ?

 

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:

  1. Add a system property by navigating to "sys_properties.list"
  2. Click the 'New' button
  3. 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.
  4. Set the 'Type' to "String"
  5. 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
  6. Save the new property
  7. Navigate to Service Portal > Widgets
  8. Query the list of widgets for 'ID' contains "widget-ticket-conversation"
  9. Open the resulting record (it should be read-only)
  10. Click the 'Clone Widget' button. A copy of the widget will be created and should be editable
  11. Give the cloned copy its own Name and ID
  12. 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)
  13. Add the code below between the first "return false" and the large comment below it (for me, that would be line 134)
  14. Edit the code snippet so that "exclude_attachments_on_convo_page" is the name of the system property from above. 
  15. Save the cloned widget.
  16. Navigate to Service Portal > Service Portal Configuration
  17. Click the Page Editor box
  18. Search for the page that contains the widget you need to edit. This is probably called "Ticket Form" (or "ticket")
  19. 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").
  20. Scroll to the bottom and locate the Widget field.
  21. Change that field from "Ticket Conversations" to whatever you named the cloned widget in the previous steps. 
  22. Save the widget instance.
  23. 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

 

We have a requirement to show the comment box of approval record

find_real_file.png

and attachment of the doc which is already attached to be made vissible on the portal side of that particular approval .

find_real_file.png

find_real_file.png

Can you please help how to attain this requirement.

That sounds like it deserves its own Community posting. I would recommend creating a new post to see if anyone can assist.