- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 07:31 AM
Hi all,
My inbound email action works with incoming email (email type = new) as follow:
- parse external ticket number from the subject string
- find (ticket.external_number = parsed number) and update SNow ticket using new GlideRecord object (because variable 'current' is not associated with the SNow ticket)
All works as expected.
The problem is: the incoming email is not displayed in the activity log, while outgoing emails for the ticket displayed correctly.
How to fix this?
As I understand, activity log displayed information from the system audit tables. Can I add all necessary information to the tables manually?
Or maybe update somehow the email record in the mailbox before it is processed to link the email with the target ticket and use 'current' to update the ticket...
Please help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2016 09:36 PM
A script similar to this should do the trick:
(function(){
//look for the 3rd-party tool Incident
var gr = new GlideRecord("incident");
if (gr.get("correlation_id", email.subject)){
//found it so let's update the SN Incident
gr.comments = "We found it - here is the contents of the new email:\n" + email.body_text;
//...whatever else you want to update would go here
gr.update();
} else {
//did not find it so we need to create a new Incident
gr.newRecord();
gr.correlation_id = email.subject;
gr.correlation_display = "Name of 3rd-Party Tool";
gr.description = email.body_text;
//...whatever else you want to update would go here
gr.insert();
}
//now update the email record so it will show up in the record's activity formatter
sys_email.target_table = "incident";
sys_email.instance = gr.getValue("sys_id");
sys_email.update();
})();
Obviously things would need to be tweaked a bit to fit your use case, such as retrieving the 3rd-party's incident number, etc... I setup the Inbound Email Action with the following assumptions/criteria:
- the emails that come in are always new ones, not replies to a SN email, so they would never have a watermark in them
- the subject of the email contains only the 3rd-party tool's incident number
- the 3rd party tool's incident number is saved in the "correlation_id" field
- the emails are coming in from a particular user record or email address (I set mine to look for my user/email address)
- once this script is run, we can skip the other Inbound Email Actions ("Stop processing" is checked)
- set to run on the "Email [sys_email]" table so the "current" objet does not waste a new Incident number each time it is run
- set to run early ("Order" = 10)
- running on the Geneva version
This way the "integration" is neatly wrapped up in just 1 record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 08:54 AM
in that case, you should be able to do this before
anotherTicketObject.get('external_number', ...);
anotherTicketObject.comments = email.body;
anotherTicketObject.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2016 12:21 AM
of course, it was not complete script, I update several fields of the ticket between 'get()' and 'update()'
I'm afraid, the system tracks updates in the 'current' only.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 08:14 AM
Hi Alex,
Since you can see outgoing, I assume that you have Sent/Received emails displayed in the activity formatter turned on, correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 08:22 AM
Hi Chuck,
Yes, the activity formatter turned on and configured properly.
I think, the system can't match the email with the ticket, no watermark/SNow number are present in the message, only external number (I store external number in my custom field to match external tickets with SNow tickets).
Regards,
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 09:19 AM
I'm assuming the "Target table" and "Target" fields on your incoming emails are blank, correct? You could try updating them from within your Inbound Email Action. You can access the mail record using the "sys_email" variable - Accessing Email Record from Inbound Email Actions. The "Target table" would be "incident" and "Target" would be the sys_id of the Incident record.