
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 01:59 AM
Hello
Today, we are using inbound action to put emails in tickets.
I would like to parse the subject of certains emails and put a certain string into a field.
I receive emails from specific email addresses with this reference in the subject SMIT-xxxx and I would like to set the field 'Salesforce ticket reference" to this value in the task table.
Can you help me to achieve this ?
I searched a bit left and right but I'm not sure how to do this , do I have to create a separate inbound action or is it a business rule ?
Thanks
Jérôme
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 05:15 AM
I managed to do it :
ParseSmit();
function ParseSmit() {
// The subject
var subjectStr = email.subject;
var regExSmit = /SMIT-\d{4}/;
var ciStr = subjectStr.match(regExSmit);
gs.log(ciStr);
current.u_jira_ticket_reference = ciStr[0];
current.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 03:24 AM
It was a simple example on how to use the trigger on a Flow to start some chain of events in ServiceNow.
You can easily create the logic of the Flow, to have it do what you need.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 03:00 AM
Hello
I tried with the following inbound action but it doesn't work 😞
Script used is the following :
(function() {
// The subject
var subjectStr = email.subject;
var ciStr = subjectStr.substring(subjectStr.lastIndexOf("SMIT-") + 4, subjectStr.lastIndexOf(" "));
var grIncident = new GlideRecord('incident');
grIncident.setValue('u_jira_ticket_reference', ciStr);
grIncident.update();
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 03:06 AM
Are you updating an existing ticket or trying to create a new one?
If new one:
var grIncident = new GlideRecord('incident');
grIncident.newRecord();
grIncident.setValue('u_jira_ticket_reference', ciStr);
grIncident.update();
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 03:07 AM
I'm trying to update existing one.
I'll need to elabore this to match the incident reference with the existing ticket , that will not be easy ;(

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 03:11 AM
Then, just use:
var subjectStr = email.subject;
var ciStr = subjectStr.substring(subjectStr.lastIndexOf("SMIT-") + 4, subjectStr.lastIndexOf(" "));
current.u_jira_ticket_reference = ciStr;
current.update();// missed this one
Aman Kumar