Commonly we find ourselves wanting to get some information out of a ticket summary to use that information for certain fields.
This is commonly a difficult task to do when working on tickets specially those that come via Email.
Today i’m here to show you how you can create an Automation that helps you out and gets that information for you and then automatically dumps it into a specific field.
For this we will be assisted by REGEX
REGEX is pattern based so we will need a couple pre-requisites before we begin:
I will Take the following example for this.
The text “Email: mail@testing.com“
In the above text my likely outcome would be to extract the E-mail so I can use it to fill a the Reporter field, or create a new user account or a multitude of options on which this can be helpful to have.
Let me break it down for you.
In the above example “Email:“ would be my recognizable pattern and “email“ will be the text to extract.
As long as we have these elements the rest of the Description or Summary can be whatever, since we know what to look for.
The other two recommendations to follow are the following:
If used in SUMMARY the text to extract would need to be at the end of the field.
If used in DESCRIPTION the text to extract needs to be in a separate line by itself and always contain a line break.
Recommendation would be to use Template as shown below:
Now that we have set the basis of how this will work we can begin!
Go to → Project Settings → Automation → Create Rule
Structure will be the following:
Trigger: Issue Created is the most common one for this example however if you need to do edits because of any other trigger you can do so as well.
Conditions: Can be any that you feel necessary
Actions: Can be any that you feel necessary.
Example
The REGEX to use in this example is :
{{issue.description.match(".*Email: (\S+).*")}}
{{issue.summary.match(".*Email: (\S+).*")}}
Breaking this down:
The part in Bold Section will be our REGEX which translates to:
. matches any character (except for line terminators) * matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy) Email: matches the characters Email: literally ( case sensitive) 1st Capturing Group (\S+) \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) + matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy) . matches any character (except for line terminators) * matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy) Global pattern flags g modifier: global. All matches (don't return after first match) m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string) |
The rest of the the line is the Smart Value that Allows us to use REGEX as part of our Automation.
For more information about Smart Values you can review this document:
And that's it! if you've made it this far it means that you have finished your Automation and you are extracting information!
A couple of notes before we leave!
You've got this!
Angel Buendia
2 comments