The CreatorCon Call for Content is officially open! Get started here.

Inbound email action - create ticket and update with Subject of email

maneesh3
Tera Contributor

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!

1 ACCEPTED SOLUTION

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

 

View solution in original post

16 REPLIES 16

Vijay Balotia1
Tera Guru

Hi @maneesh3 

 

As you mentioned client is sending unique ticket Number, so when ticket is created by email at the same time parse the subject and you can use OOTB field correlation ID where use can store the Jira Ticket number

In your email action script you can easily check if any ticket is created w.r.t Jira ticket Number and accordingly you can create or update new tickets

 

Thanks,

Vijay Balotia

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Thanks
Vijay Balotia

Hi Vijay,

 

Thanks a lot response. Is there any script that you can help me here please.

 

Thank you!

Hi @maneesh3,

 

You can use below code to create and update based on subject. lets say you are receiving email subject as : JIRA TKT NO Task7434234 (Task7434234 is your Jira task number)

 
//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);
 
if(current.correlation_id==jiraTicketNo){
current.worknotes=email.body_text;
//similarly you can add more fields that you want to add.
current.update();
}else{
current.correlation_id= jiraTicketNo;
current.short_decription= email.subject;
//similarly you can add more fields that you want to add.
current.insert();
}
  

Thanks,

Vijay Balotia

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Thanks
Vijay Balotia

Hi Vijay,

 

I have used same script but still getting new tickets created for same subject: kindly let me know if i miss anything here:

 

maneesh3_0-1695203519273.png

 

code:

maneesh3_1-1695203588573.pngmaneesh3_2-1695203632290.png

 

Thanks a lot for help here!