- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 05:58 AM
Hi Team,
I have an requirement to create and update ticket with subject line instead of watermark. Client will send emails from JIRA system. They will have unique subject for each ticket sending to SNOW.
for example:
Subject: JIRA TKT NO 74
So I need now to create ticket for the first email and next emails with same subject should be updated. Client did not have feasibility to send thread of emails , and everytime they send as new emails.
Please suggest code to do in inbound email actions
Help much appreciated. Thank you!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 10:21 AM - edited 09-26-2023 10:22 AM
Hi @maneesh3,
If your subject is [JIRA] (C2SD-74) TEST and you wants C2SD-74. then you can use the below regex to get the result
var jiraTicketNo = subjectStr.match(/\(([^)]+)\)/)[1].toString();
and comment out var regExSmit = /Task\d{6}/; line
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Thanks
Vijay Balotia

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 07:43 AM
@maneesh3 In your Inbound email action script, make following changes.
// Note: current.opened_by is already set to the first UserID that matches the From: email address
var glideIncident = new GlideRecord('incident');
glideIncident.addEncodedQuery('short_description=' + email.subject);
glideIncident.query();
if (glideIncident.next()) {
glideIncident.caller_id = gs.getUserID();
glideIncident.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
glideIncident.short_description = email.subject;
glideIncident.category = "inquiry";
glideIncident.incident_state = IncidentState.NEW;
glideIncident.notify = 2;
glideIncident.contact_type = "email";
if (email.body.assign != undefined)
glideIncident.assigned_to = email.body.assign;
if (email.importance != undefined) {
if (email.importance.toLowerCase() == "high") {
glideIncident.impact = 1;
glideIncident.urgency = 1;
}
}
glideIncident.update();
} else {
current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
current.category = "inquiry";
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";
if (email.body.assign != undefined)
current.assigned_to = email.body.assign;
if (email.importance != undefined) {
if (email.importance.toLowerCase() == "high") {
current.impact = 1;
current.urgency = 1;
}
}
if (current.canCreate())
current.insert();
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 12:49 AM
Hi Sandeep,
Thanks a lot response. I have tried the script and it is creating new tickets 2nd time when same subject email is received:
I should be able to update ticket if received same subject, below is the part in inbound action I have implemented, please help if I am missing anything:
Thanks for the help here!