We have a custom date field in JPD that allows the user to select a quarter, a month, or a single date. In an automation rule, I need to reference that date field and extract the date value.
Using smart values, this:
{{customfield_20469}}
returns:
{"start":"2024-04-01","end":"2024-06-30"}
The following reference all return empty string
{{customfield_20469.value}}
{{customfield_20469.start.value}}
{{customfield_20469.start.toDate}}
{{customfield_20469.start.jiraDate}}
{{customfield_20469.toDate}}
{{customfield_20469.jiraDate}}
What do I use in the automation to get "2024-04-01" or "2024-06-30"?
Hi @jbrowne -- Welcome to the Atlassian Community!
JPD is using this different version of a date field, apparently to store ranges, as needed.
And so text functions are needed to extract the values: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/
For example one way to do this with your field...
start date: {{issue.customfield_20469.match(".*start\":\"(.*)\",.*").toDate}}
end date: {{issue.customfield_20469.match(".*end\":\"(.*)\".*").toDate}}
One benefit of explicitly trying to match the format is seeing errors if Atlassian changes it in the future.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy– If I wanted to port these values to another date field in JPD, how would I do that using the advanced field editing option in Jira Automation if I stored the extracted data via Smart Values?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Casey Meyer
You could use the date-type fields to format them back into the JPD-date-type fields. That format looks like this, as an example:
"customfield_10107": "{\"start\":\"2023-10-18\",\"end\":\"2023-10-18\"}"
Thus you could substitute in your date fields, formatted with jiraDate, perhaps like this:
"customfield_10107": "{\"start\":\"{{issue.someDate.jiraDate}}\",\"end\":\"{{issue.someOtherDate.jiraDate}}\"}"
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy– That worked perfectly! Saved me a lot of effort and time trying to figure it out on my own haha, Much appreciated!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.