Sent/Recieved Emails in Ticket Conversations widget

Simon Christens
Kilo Sage

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

37 REPLIES 37

ginakuntz
Kilo Contributor

Hi, I have successfully tested this configuration on the inbound email action that manages reply emails from customers -


Screen Shot 2017-07-17 at 12.40.10 PM.png



The email was viewable in the conversation widget as text.   Not sure if anyone else has seen this as an option, but it seems to achieve the desired effect.  



Hope this helps!


*gina*


Hi Gina



You are copying the email content to Additional comments and thats exactly want is want not to do. When the content i copied to comments then its also visible for ITIL users.


Also im pretty sure that its OOTB functionality.



What I want is that Portal users gets access to email content within a record without copying it to Additional comments


ewok
Giga Contributor

Thanks for sharing this as this was able to solve my problem. Going to add a little more detail about my issue and how I solved it for others. My problem to was we wanted to see emails in update to cases in our service portal. However the ticket conversions widget even after enabling the system property glide.ui.activity.email_roles with a role that our customers had they were still not able to see the updates via the service portal. Good to note that this setting allowed our customers to see the updates via the standard servicenow interface. However they would never have a link to the case in the internal portal so really didn't solve our problem. 

 

 

find_real_file.png

 

So as mentioned I created a new field in the case table called additional comments to place the updates. Here are the details for that field. 

 

find_real_file.png

 

After that I just needed to populate the body of the email to the additional comments. I used an email inbound action rule for that. It matches the subject of an email looking for a case number with a regular expression (.*[Cc][Ss]\d{7}.*). Here is that rule. Make sure the rule is low enough so that it executes.

 

find_real_file.png

 

 

The action taken is to add an update to the case in the new additional comments field from the body of the email. It sets the update by to the sender of the email. So that means the sender needs to have an account in servicenow. Also new to me  you have to have the Ref:MSG111111 created for the ticket in the body of your email. This is required to map the updates back to the right case. I initially was not including that and it was creating a new case. This MSG id is created any time an email is sent out from service now. 

 

 

 

find_real_file.png

 

 

Anyone have any additional questions let me know or PM me if you wish. 

Chris P_
Tera Expert

I kinda went with a different approach, since I wanted to see emails in the activity list on the portal as well, why not get them from the sys_email table?

Here's the code:

record.stream = $sp.getStream(options.table, record.sys_id);

//Below code adds rows to the array which $sp.getStream creates
var mailgr = new GlideRecord('sys_email');
		mailgr.addQuery('instance',record.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();
				record.stream.entries.push(tempobj);
			}
// 			else {
// 				tempobj.user_sys_id = '';
// 				tempobj.name = "system";
// 			}
			
		}

//Now we just need to re-sort the array so the output is correct
		record.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);} );

So hope this helps everyone with the same question 🙂

Where are you adding this? I tried it on the Server Side of the ticket conversation widget but does not seem to work.