How to automate startDate/endDate with Fix Version set ?
Asked by Pierre VIAU:

Hello !

We are working on a environment with :

* Jira
* Jira Automation
* Jira Plan

I want to create a Roadmap that is easy to use so as soon as a fixVersion is set on an Epic (or an Initiative), I would like to update the Target Start or Target End.

++First issue :++   
Those fields are not available from Automation

++Second issue :++   
*(I decided to choose 2 other date fields)*I failed to compute my start date, it worked for my end date.

Here are my formulas :

```
Start Date :?{{issue.fixVersions.startDate.min}}
End Date :?{{issue.fixVersions.releaseDate.max}}
```

Do you have any idea why ?


Answers:
author: Yvan Martin
body: Hi [@Pierre VIAU](/t5/user/viewprofilepage/user-id/4387017) ,

<br />

Developer from Automation here.  

We currently don't have proper support for advance roadmaps, here's the public issue in our tracker encase we do at a later stage: <https://community.atlassian.com/t5/Automation-questions/How-to-automate-startDate-endDate-with-Fix-Version-set/qaq-p/1689148>  

<br />

In terms of accessing fields you can use max and min over a list like fix versions, the thing to note with {{issue.fixVersions}} would be that it's the fixVersions attached to that particular issue, so if one of the dates is failing it could be that the ones attached don't have a startDate since it's optional on fixVersions. You might have to put conditions to ensure they are there before editing the date field.  

If you require further help with fixVersions smart value then I suggest reaching out to support here: <https://support.atlassian.com/>  

![Screen Shot 2021-05-14 at 4.16.18 pm.png](https://community.atlassian.com/t5/image/serverpage/image-id/143436i7BE42C2C0C8E03F1/image-size/large?v=v2&px=999 "Screen Shot 2021-05-14 at 4.16.18 pm.png")  

<br />

![Screen Shot 2021-05-14 at 4.16.49 pm.png](https://community.atlassian.com/t5/image/serverpage/image-id/143437i74875275D07199EA/image-size/large?v=v2&px=999 "Screen Shot 2021-05-14 at 4.16.49 pm.png")

comments: author: Darryl Lee
body: Thanks - good to have an authoritative answer on this!


author: Jerome BERTRAND
body: Hello Pierre,

Your second issue is actually of problem of date type conversion.  
releaseDate and startDate attributes are not the same type.

This made the trick for me:

```
Start Date :?{{issue.fixVersions.startDate.jiraDate.toDate.min}}
End Date :?{{issue.fixVersions.releaseDate.max}}
```


author: Pierre VIAU
body: Many thanks Darryl and Yvan :)

I will try again to work on my automation soon and be back to you with my solution !

comments: author: Pierre VIAU
body: For information, I was able to automate the setting that way :

```
{
"fields": {
"customfield_12807" : "{{issue.fixVersions.startDate.first}}",
"customfield_12808" : "{{issue.fixVersions.releaseDate.max}}"
}
}
```

Where the 2 custom fields are Target start and Target end dates, used in our Portfolio :)


author: Bill Sheboy
body: Hi [@Pierre VIAU](/t5/user/viewprofilepage/user-id/4387017)

Just to confirm, are you certain the following works as you expect?

```
{{issue.fixVersions.startDate.first}}
```

Fix Versions is a list field, and so the above smart value will return the startDate of the **first item in the list, regardless of the order of the values (or the position of the start date in that list**). My understanding is that list fields do not have a built-in ordering mechanism, so your return value will be whatever order the values are given by Jira.

Best regards,  
Bill


author: Darryl Lee
body: Hi! So you're using **min** and **max**. But I don't think that works with lists, and to be clear, because you can have multiple Fix Versions for an issue, the {{issue.fixVersions}} smart value is a list. And so when you reference startDate or releaseDate, those too are lists.

There's some good documentation about this here:

<https://blog.codebarrel.io/automation-for-jira-smarter-smart-values-9da5598f2bdc>

So, to clarify, are you trying to deal with the case where there are multiple fixVersions for an issue? If not, then you should just be able to use:

```
Start Date :?{{issue.fixVersions.startDate.last}}
End Date :?{{issue.fixVersions.releaseDate.last}}
```

(This assumes there's only one Fix Version, or that you want to get the start/release dates of the most *recently added* Fix Version.)

If you actually have multiple Fix Versions and you do actually need to determine which date is earliest/oldest, I wonder if there's some kind of complex formula you could use with **.isAfter** or **.isBefore**.

Here's a listinng of the functions available to date fields:

<https://support.atlassian.com/jira-software-cloud/docs/smart-values-date-and-time-functions/>

comments: author: Darryl Lee
body: Apologies. I don't work enough with Roadmaps or Epics, so I think I misunderstood your question.

I **think** this previous answer should do the trick:

<https://community.atlassian.com/t5/Jira-Software-questions/How-to-use-Automation-to-set-Epic-s-start-amp-end-date-equal-to/qaq-p/1497229>

Looks the fields you'll want to set are named End Date and Start Date.

And you might need to format the date you get from **fixVersions** using **jiraDateTime.**


author: Darryl Lee
body: Ugh, actually I misread that last post I linked to. It was talking about Start Date and Due Date, but neither are linked to Target Start/End. Those do not appear to be accessible via Automation.

On my test Cloud instance, I don't even know where the **Start Date** field came from. I think it may have been created when I set up project based on the "IT service management" Template.

![startdate.png](https://community.atlassian.com/t5/image/serverpage/image-id/142875iB3E4A5C6E1627ABF/image-size/large?v=v2&px=999 "startdate.png")

Under Plan Configuration there appears to be a way to use different fields in Plans. Perhaps that's worth looking at?

![Screen Shot 2021-05-10 at 1.00.58 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/142876i41BE386261BD755E/image-size/large?v=v2&px=999 "Screen Shot 2021-05-10 at 1.00.58 PM.png")

There's more details on this here: <https://confluence.atlassian.com/advancedroadmapscloud/configure-plan-settings-998650959.html#Configureplansettings-dates>

But again, I'm not an expert in **Advanced roadmaps**, so perhaps somebody else could chime in on what the best practice is here.


Tags: plan