Smart Values for Custom Start/End Date field

jbrowne May 9, 2024

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"?

1 answer

1 accepted

2 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 9, 2024

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

jbrowne May 9, 2024

@Bill Sheboy - Perfect!  Thank you so much

Like Bill Sheboy likes this
KCM June 9, 2024

@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?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2024

Hi @KCM 

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

Like KCM likes this
KCM June 12, 2024

@Bill Sheboy– That worked perfectly! Saved me a lot of effort and time trying to figure it out on my own haha, Much appreciated!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events