- 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-21-2023 11:31 PM
Please suggest on above issue. Is there any wrong which I have included in code.
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 12:26 PM - edited 09-22-2023 12:27 PM
Hi @maneesh3,
Sorry for delay in response. please use this code for sure it will work.
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
//var subjectStr = "JIRA TKT NO Task7434234 ";
var subjectStr = email.subject;
var regExSmit = /Task\d{6}/; //you can adjust this based on your subject.
var jiraTicketNo = subjectStr.match(regExSmit).toString();
var gr = new GlideRecord("sn_customerservice_case");
gr.addQuery("correlation_id", jiraTicketNo);
gr.query();
if (gr.next()) {
gr.worknotes = email.body_text;
//similarly you can add more fields that you want to add.
gr.update();
} else {
gr.correlation_id = jiraTicketNo;
gr.short_decription = email.subject;
//similarly you can add more fields that you want to add.
gr.insert();
}
// Implement email action here
})(current, event, email, logger, classifier);
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-26-2023 02:11 AM
Hi Vijay,
Perfect its working now. Last help for Subject line like below what should regex :
[JIRA] (C2SD-74) TEST -- ABC ---> I should take only C2SD-74
Also is there any document or reference I can play with subject lines.
Thanks

- 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:25 AM
Hi @maneesh3
Greetings!!
Here is link to understand / solve your problem:
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************