Capture Priority and Organization Values from the table under the Description field.
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
要約
The Regex expression is used to extract the values of the Priority and Organisation fields from the table located within the Description field.
診断
The requirement was to capture custom field data from a table sent under the Description field via email. The data format is as follows:
To capture these values in a custom field, the following conditions must be met:
- The data format in the table must always be consistent.
- The field values sent in the table must match the existing values/options in the custom field.
ソリューション
First, we will need to analyze the data format and to achieve this we will use Jira Automation where we will first capture Description field data in a Variable as follows:
In the Automation logs, we observe that the table data is captured in a "|" format. This insight helps us create a regex expression to capture the table data effectively.
To capture the Priority and other custom field data we will add Variables to our Automation and assign it the following values:
For Priority: {{issue.description.substringBetween("|Priority|","|")}}
For Affected Components: {{issue.description.substringBetween("|Affected Component|","|")}}
For Summary: {{issue.description.substringBetween("|Summary|","|")}}
To update the field value, we will pass the "Variable name" as the value for the required custom field.
Now, the challenge is to capture the Organization's field value. If you just pass the "Variable name" as the value for the Organisation field, Jira Automation won't let you pass the smart value under this field.
To resolve this problem we will use the "Send Web Request" action. Before that, we will capture the Organisation from the table and store it inside a variable as follows:
The "Web request URL" that we will use here is "https://<Site URL>/rest/servicedeskapi/organization", and the "HTTP method" will be "POST". This will check if the Organization value captured from the table exists in the Project Organization else it will create a new Organization in that project.
Now we will pass the above "Variable name" for Organization under the "Custom data".
We will now capture the Webhook Response in a "Log Action" to see the output of the "Send Web Request" action. If the captured Organization exists, Jira Automation will show us the Organization ID and link in the Audit logs; otherwise, it will create a New Organization in that concerned project.
{{webhookResponse.body}}
Now, we can use this generated ID to update the Organization's custom field by passing the following JSON under the Advance function "Additional fields".
{
"fields": {
"customfield_10002": [{{webhookResponse.body.id}}]
}
}