Sent/Recieved Emails in Ticket Conversations widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2017 09:33 PM
Hi Community
Is there anyone in here who have tried to incorporate the "Sent/Recieved Emails" functionality into the Ticket Conversations widget?
The obvious upside for this is that if you do not copy email content into comments its still possible for the end user to see mails back and forth.
Regards
Simon
- 7,493 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-25-2022 09:39 AM
Has anyone implemented this as of late? I can't find the exact line Chris is talking about.
Will mark as helpful etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2018 08:59 AM
Well I added it to a custom widget, but its based on widget:
ID: widget-ticket-conversation
Name: Ticket Conversations
It has the $sp.getStream function on line 63 of the server script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2018 01:15 AM
Ow and also (just to be complete) replace the 'record.sys_id' with 'data.sys_id' in the added code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2019 04:04 AM
Hi Chris,
I am trying to implement the same and have made the necessary changes to from record to data but still not working . We are currently in London version and blow is the Service Side Script . Please let me know if i am missing some thing
/////////////////////////////////////////// Script //////////////////////////////////////
(function() {
data.maxAttachmentSize = parseInt(gs.getProperty("com.glide.attachment.max_size", 1024));
if (isNaN(data.maxAttachmentSize))
data.maxAttachmentSize = 24;
data.uploadingAttachmentMsg = gs.getMessage("Uploading attachment...");
data.sharingLocMsg = gs.getMessage("Sharing location...");
data.scanBarcodeMsg = gs.getMessage("Scan barcode");
data.checkInLocMsg = gs.getMessage("Check in location");
data.messagePostedMsg = gs.getMessage("Message has been sent");
data.viewMsg = gs.getMessage("View");
data.attachAddedMsg = gs.getMessage("Attachment added");
data.attachFailMsg = gs.getMessage("Failed to add attachment");
data.sys_id = input.sys_id || options.sys_id || $sp.getParameter("sys_id");
data.table = input.table || options.table || $sp.getParameter("table");
// don't use options.title unless sys_id and table also come from options
if (options && options.sys_id && options.table)
data.ticketTitle = options.title;
data.placeholder = options.placeholder || gs.getMessage("Type your message here...");
data.placeholderNoEntries = options.placeholderNoEntries || gs.getMessage("Type your message here...");
data.btnLabel = options.btnLabel || gs.getMessage("Send");
data.includeExtended = options.includeExtended || false;
data.use_dynamic_placeholder = options.use_dynamic_placeholder;
data.isNewRecord = data.sys_id == -1 || gr.isNewRecord();
var gr = new GlideRecord(data.table);
if (!gr.isValid())
return;
gr.get(data.sys_id);
if (!gr.canRead())
return;
data.table = gr.getRecordClassName(); // use actual table for the record
options.no_readable_journal_field_message = options.no_readable_journal_field_message || gs.getMessage("No readable comment field");
data.number = gr.getDisplayValue('number');
data.created_on = gr.getValue('sys_created_on');
if (input) { // if we have input then we're saving
if (input.journalEntry && input.journalEntryField){
if (gr.canWrite(input.journalEntryField)){
gr.setDisplayValue(input.journalEntryField, input.journalEntry);
gr.update();
$sp.logStat('Comments', data.table, data.sys_id, input.journalEntry);
}
}
data.ticketTitle = input.ticketTitle;
data.placeholder = input.placeholder;
data.btnLabel = input.btnLabel;
data.includeExtended = input.includeExtended;
} else {
if (!data.ticketTitle) {
if (gr.short_description.canRead())
data.ticketTitle = gr.getDisplayValue("short_description");
if (!data.ticketTitle)
data.ticketTitle = data.number;
}
$sp.logStat('Task View', data.table, data.sys_id);
}
data.canWrite = gr.canWrite();
data.canAttach = gs.hasRole(gs.getProperty("glide.attachment.role")) && GlideTableDescriptor.get(data.table).getED().getAttribute("no_attachment") != "true";
data.canRead = gr.canRead();
data.hasWritableJournalField = false;
data.hasReadableJournalField = false;
if (data.canRead && !data.isNewRecord) {
data.stream = $sp.getStream(data.table, data.sys_id);
//Below code adds rows to the array which $sp.getStream creates
var mailgr = new GlideRecord('sys_email');
mailgr.addQuery('instance',data.sys_id);
mailgr.query();
while (mailgr.next()) {
var tempobj = {};
tempobj.element = "comments";
tempobj.field_label = "Additional comments";
tempobj.sys_created_on = mailgr.sys_created_on.toString();
tempobj.sys_created_on_adjusted = mailgr.sys_created_on.getDisplayValue().toString();
tempobj.sys_id = mailgr.sys_id.toString();
tempobj.user_sys_id = 'system';
tempobj.name = "system";
if (mailgr.sys_created_by != 'system' || mailgr.mailbox.getDisplayValue() == "Received") { //This filters the creation mail and other assignment group mails etc...
var usergr = new GlideRecord('sys_user');
usergr.addQuery('user_name',mailgr.sys_created_by.toString());
usergr.query();
if (usergr.next()) {
tempobj.user_sys_id = usergr.sys_id.toString();
tempobj.name = usergr.name.toString();
}
var mailtype = "";
if (mailgr.mailbox.getDisplayValue() == 'Sent') mailtype = "<strong>Sent email:</strong> \n";
else mailtype = "<strong>Received email:</strong> \n";
tempobj.value = mailtype + mailgr.body_text.toString();
data.stream.entries.push(tempobj);
}
}
//Now we just need to re-sort the array so the output is correct
data.stream.entries.sort(function(a,b) {return (a.sys_created_on_adjusted < b.sys_created_on_adjusted) ? 1 : ((b.sys_created_on_adjusted < a.sys_created_on_adjusted) ? -1 : 0);} );
// Journal fields come in correct order already
// so grab the first 2 writeable fields
if ('journal_fields' in data.stream) {
var jf = data.stream.journal_fields;
for(var i=0; i < jf.length; i++){
if (jf[i].can_read === true)
data.hasReadableJournalField = true;
if (jf[i].can_write === true){
data.hasWritableJournalField = true;
if (!data.primaryJournalField)
data.primaryJournalField = jf[i];
else if (data.includeExtended && !data.secondaryJournalField)
data.secondaryJournalField = jf[i];
else
break;
}
}
}
}
data.tableLabel = gr.getLabel();
})()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2018 06:15 AM
Simon, did you achieved your requirement?