This workaround is meant to help projects where it is necessary to get information from an email request's description field and enter it into specific Jira Custom fields. This saves time in a daily routine by not having to enter the values manually.
For this, we can utilize Automation For Jira (A4J) with some Jira Custom Fields. I used an Email request related to HR - New Hire as an example, where a user will send the new hire information via email based on a list.
You will need system automation to load the same default list in your browser email - this process can be done with iCIMS or other tools automation in your system. This method can be used for other purposes like Email Requests containing a shopping list, an incident, etc.
Important related documentation:
Smart values - text
Text functions
Regular expressions
I was able to get the information by rows in the Description field and throw that information into Jira's fields.
The bulk of the work is done by the Smart Value match() expression with Regular expressions in A4J.
This example would capture the entire Description, which isn't very useful.:
{{issue.description.match("(.*)")}}
The feature we will be using from Regular Expressions is the Capture Group:
The Regular Expression will take different forms depending on what you are trying to capture, but here is a practical example to give an idea of how it can be used.
Let's say the Email Request creates an Issue with a Description with this Information:
Employee Name: John Doe
Employee Number: AB00123
Hire Date: 31/02/2023
Each of these Smart Values will capture their respective lines:
{{issue.description.match("^Employee Name: (.*)$")}}
{{issue.description.match("^Employee Number: (.*)$")}}
{{issue.description.match("^Hire Date: (.*)$")}}
Written plainly, they are saying:
Where all require that the Strings it is checking for are at the beginning of the line.
You will be able to get the row info after this delimited text. The automation rule will work as in the screen recording below:
In addition, in order to parse a text field to a date field format, the date filled in the text field will need to be in the format "yyyy-MM-dd". Otherwise, you will receive the error below:
Error editing issues
Project-Key (The Date form must be of the format "yyyy-MM-dd" (customfield_xxxx))
Note: The email must be without any formatting, otherwise, it will copy the HTML for color, letter format, etc, as shown in this screenshot:
f you need assistance with updating a user-picker field based on the Description, please feel free to review this helpful article: Populate a user picker field from the description field
Also, to work with Single and Multi-select fields, you can use Advanced field editing through JSON, which can be applied to all fields.
Here is an example JSON setup for the Customer - customfield_10322 (single choice field) and Customers (multiple choices field):
{ "fields": {"customfield_10322": {{issue.description.match("Customer: (.*)").trim().asJsonObject("value")}}, "customfield_10323": [ {{issue.description.match("Customers: (.*)").split(",").trim().asJsonObject("value")}} ] } }
In this example, we extract the values, remove any spaces, and convert each field into a JSON object.
For the Customers field, a multi-select field expecting an array of values, we use the split feature to handle the values separated by a comma.
You can find more details and a demonstration in the video below:
Bruno Altenhofen
Atlassian Engineer - The guy from Proforma(Jira Forms)
e-Core
Krakow - Poland
1 comment