How to Pull long date(eg: February 20, 2023) from Summary of an issue using Jira Automation
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
How to Pull a long date(for example: February 20, 2023) from the Summary of an issue and edit the "Start Date" custom field using Jira Automation.
Environment
The custom field "Start Date test" is a "Date Picker" field.
Solution
Following JSON code contains smart values which needs to be mentioned in "Additional Fields" section of "Edit Issue" action.
{
"fields": {
"customfield_10082": "{{issue.summary.match("(\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May(?:)?|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sept(?:ember)?|Oct(?:ober)?|Nov(?:ember)|Dec(?:ember)?) (\b\d{1,2}\D{0,3})?.\s\b(?:19[7-9]\d|2\d{3}))").toDate("MMMM dd, yyyy").format("yyyy-MM-dd")}}"
}
}
Automation Preview:
How it works is explained below:
- My custom field id for Start Date test is "customfield_10082"
- Used Smart value "issue.summary.match" along with Regual Expression(REGEX) which will fetch the date in string format.
- Used ".toDate("MMMM dd, yyyy")" to convert string into date format.
- Then format date from "MMMM dd, yyyy" to "yyyy-MM-dd" using ".format("yyyy-MM-dd")}}" as my format on custom field is yyyy-MM-dd.