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

Tim Deniston
Mega Sage
Mega Sage

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. 

Community Alums
Not applicable

Hello @Tim Deniston 

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 

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. 

Community Alums
Not applicable

Hello @Tim Deniston 

Thank you so much for your help. 

 

Regards,

Ganesh