Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation - how do I compare multiple date fields from the same issue and insert the earliest date?

Andy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 25, 2025

In Automation, I want to find the earliest date from a list of dates and use it to populate another field within the same issue.


For example, in my issue, I may have a list of dates like:

  • Custom Field 1: May 10
  • Custom Field 2: April 5
  • Custom Field 3: June 1

I want to look at all those dates and pick the one that comes first — April 5 — and set another field using that date.


My list of fields are:

  • Custom Fields:
    • issue.customfield_10652
    • issue.customfield_10713
    • issue.customfield_10659
    • issue.customfield_10677
    • issue.customfield_10683
    • issue.customfield_10689
    • issue.customfield_10701
    • issue.customfield_10695
    • issue.customfield_10707
    • issue.customfield_10671
    • issue.customfield_10557
    • All Date Picker fields
  • Field to insert the earliest date to:
    • issue.customfield_10015
    • Date Picker field

The output of field is "customfield_10652":"2025-04-25".

I have tried the following (with a reduced number of fields):

--------------

Create Variable

Variable Name = TestVariable
Smart Value = {{[issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].min}}

Unable to render smart values when executing this rule:
Failed to get value for [issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].min: {{[issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].min}}

It should show "25 Apr 2025".

--------------

Log Action

Log message = {{[issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].min}}

Unable to render smart values when executing this rule:
Failed to get value for [issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].min: Earliest Date: {{[issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].min}}

It should show "25 Apr 2025".

--------------

Edit work item

Field = Start date
Value = {{[issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].min}}

Error - Unable to render smart values when executing this rule:
Failed to get value for [issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].min: {{[issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].min}}

It should show "25 Apr 2025".

--------------

Create Variable

Variable Name = TestVariable
Smart value = {{[issue.customfield_10652.jiraDateTime, issue.customfield_10713.jiraDateTime, issue.customfield_10659.jiraDateTime].min}}

Unable to render smart values when executing this rule:
Failed to get value for [issue.customfield_10652.jiraDateTime, issue.customfield_10713.jiraDateTime, issue.customfield_10659.jiraDateTime].min: {{[issue.customfield_10652.jiraDateTime, issue.customfield_10713.jiraDateTime, issue.customfield_10659.jiraDateTime].min}}

It should show "25 Apr 2025".

--------------

Edit work item

Field = Start date
Value = {{[issue.customfield_10652.jiraDateTime, issue.customfield_10713.jiraDateTime, issue.customfield_10659.jiraDateTime].min}}

Error - Unable to render smart values when executing this rule:
Failed to get value for [issue.customfield_10652.jiraDateTime, issue.customfield_10713.jiraDateTime, issue.customfield_10659.jiraDateTime].min: {{[issue.customfield_10652.jiraDateTime, issue.customfield_10713.jiraDateTime, issue.customfield_10659.jiraDateTime].min}}

It should show "25 Apr 2025".

--------------

Create Variable

Variable Name = TestVariable
Smart Value = {{#=}}min({{issue.customfield_10652}}, {{issue.customfield_10713}}, {{issue.customfield_10659}}){{/}}

Log = "TestVariable: 1995"

It should show "25 Apr 2025".

--------------

Create Variable

Variable Name = TestVariable
Smart Value = {{#=}}min({{issue.customfield_10652.jiraDate}}, {{issue.customfield_10713.jiraDate}}, {{issue.customfield_10659.jiraDate}}){{/}}

Log = "TestVariable: 1994"

It should show "25 Apr 2025".

--------------

Create Variable

Variable Name = TestVariable
Smart Value = {{#=}}min({{issue.customfield_10652.jiraDateTime}}, {{issue.customfield_10713.jiraDateTime}}, {{issue.customfield_10659.jiraDateTime}}){{/}}

Error - Unable to render smart values when executing this rule:
Unknown operator : at character position 18: min(2025-04-26T00:00:00.0+0000, 2025-04-25T00:00:00.0+0000, 2025-04-25T00:00:00.0+0000)

It should show "25 Apr 2025".

--------------

Create Variable

Variable Name = TestVariable
Smart Value = {{[issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].filter(notNull).min}}

Error - Unable to render smart values when executing this rule:
Failed to get value for [issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].filter(notNull).min: {{[issue.customfield_10652, issue.customfield_10713, issue.customfield_10659].filter(notNull).min}}

It should show "25 Apr 2025".

--------------

Edit work item

Advanced fields =

{
"fields": {
"customfield_10015": "{{issue.customfield_10652.jiraDate.min(issue.customfield_10713.jiraDate).min(issue.customfield_10659.jiraDate)}}"
}
}

Error - Error editing work items
PMOV2-476 (The Start date must be of the format "yyyy-MM-dd" (customfield_10015))

It should show "25 Apr 2025".

--------------

Edit work item

Advanced fields =

{
"fields": {
"customfield_10015": "{{issue.customfield_10652.jiraDate.min(issue.customfield_10713.jiraDate).min(issue.customfield_10659.jiraDate).toString(\"yyyy-MM-dd\")}}"
}
}

Error - Error editing work items
PMOV2-476 (The Start date must be of the format "yyyy-MM-dd" (customfield_10015))

It should show "25 Apr 2025".

--------------

Edit work item

Advanced fields =

{
"fields": {
"customfield_10015": "{{issue.customfield_10652.min(issue.customfield_10713).min(issue.customfield_10659).toString(\"yyyy-MM-dd\")}}"
}
}

Error - Error editing work items
PMOV2-476 (The Start date must be of the format "yyyy-MM-dd" (customfield_10015))

It should show "25 Apr 2025".

1 answer

1 accepted

2 votes
Answer accepted
Ana Livia Rocha Silva April 25, 2025

Hi @Andy 

 

I believe the problem is that you need to create a variable for the custom fields before comparing them. Here's a post with a very similar question that got resolved:

https://community.atlassian.com/forums/Jira-questions/I-need-to-create-an-automation-that-compare-4-date-picker-custom/qaq-p/2786103

 

Kind regards,

Ana 

Andy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 25, 2025

Thank you @Ana Livia Rocha Silva :-) That was driving me crazy!

This was solved by first creating a variable with the smart values "{{issue.FieldA.jiraDate}},{{issue.FieldB.jiraDate}},{{issue.FieldC.jiraDate}},{{issue.FieldD.jiraDate}}" (replace with fields required).

Then in the edit issue action, chose the field to set and add "{{VARIABLENAME.split(",").toDate.min}}".

This also works if a field being compared is blank (but it will not work if all of the dates are empty).

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events