I need to create an automation that compare 4 date picker custom fields and put the value in other

Sofia Grunspan
Contributor
August 15, 2024

I need to create an automation rule that allows me compare four date picker custom fields and put the furthest one in a custom field of the same type named "Final Date".

The problem I've found is one of those fields to be compared can be empty.

Do you have any idea how can I structure this?

 

I have 4 data fields which I need to compare properly whenever the value of one of them changes and then select the furthest date of all and put value of it into "Final Date" field. Unfortunately if one of them has the value ‘empty’ the automaton doesn't know how to treat it so I have to add also a validation that checks if the field is empty.To do this, I need to create something like this (Example for fieldA):
----------------------------------------------------
If FieldB is empty
Or
IF FieldA is after(further) Field BAndIf FieldC is empty
Or
IF FieldA is after(further) Field CAndIf FieldD is empty
Or
IF FieldA is after(further) Field DThen put value from fieldA into "Final Date"

2 answers

1 accepted

1 vote
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.
August 15, 2024

Hi @Sofia Grunspan 

Do you only need the maximum value or do you need to know the specific field?  If you only need the maximum value...

One way to do this is to combine the date values to form a list, and then find the maximum value.  For example:

  • action: create variable (This will create a comma-separated values list of the dates.)
    • name: varDateList
    • smart value:
{{issue.FieldA.jiraDate}},{{issue.FieldB.jiraDate}},{{issue.FieldC.jiraDate}},{{issue.FieldD.jiraDate}}
  • action: edit issue, to set Final Date to this value, which splits the values, converts them back to dates, and then finds the maximum value.
{{varDateList.split(",").toDate.max}}

 

This will handle if zero or more of the dates are empty, but it will not handle if all of the dates are empty.  What do you want to do in that case?

 

Kind regards,
Bill

Sofia Grunspan
Contributor
August 16, 2024

Hi Bill thanks for answer, I've tried to implement what you suggested but the value is incompatible with Final Data field type.

1.jpg2.jpg

Like Arshiya Sultana likes this
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.
August 16, 2024

Does your scheduled trigger have any JQL to provide issues to the rule steps?

That error message indicates your rule does not have an issue for a source of the edit.

Sofia Grunspan
Contributor
August 19, 2024

You were right, I've corrected that and it worked.

Thanks a lot!

 

Like Bill Sheboy likes this
0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 15, 2024

Hello @Sofia Grunspan 

Welcome to the Atlassian community.

Can you clarify the point you are making about one of the fields being empty? Is that a permissible state? Do you want to ignore the empty fields?

What if one of the fields gets changed after the automation has run? Do you want this automation to run every time one of the fields is updated?

Sofia Grunspan
Contributor
August 15, 2024

I've changed the explanation to be more clear:

I have 4 data fields which I need to compare properly whenever the value of one of them changes and then select the furthest date of all and put value of it into "Final Date" field. Unfortunately if one of them has the value ‘empty’ the automaton doesn't know how to treat it so I have to add also a validation that checks if the field is empty.To do this, I need to create something like this (Example for fieldA):
----------------------------------------------------
If FieldB is empty
Or
IF FieldA is after(further) Field BAndIf FieldC is empty
Or
IF FieldA is after(further) Field CAndIf FieldD is empty
Or
IF FieldA is after(further) Field DThen put value from fieldA into "Final Date"

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 15, 2024

Hello Sofia,

I have unclicked the Accept Answer button on your behalf because I haven't actually provided an answer for you yet. :-)

I'm going to have to spend a bit of time thinking about this one.

Like Sofia Grunspan likes this
Sofia Grunspan
Contributor
August 16, 2024

Do you want to ignore the empty fields? yes

What if one of the fields gets changed after the automation has run? Do you want this automation to run every time one of the fields is updated? yes

I think if I put Schedule as trigger I can do that.

Suggest an answer

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

Atlassian Community Events