Jira Automation - Get the version with start/release date fit specific date
Asked by Micha?:

Hi,

working on data center automation I try to get Version which start and release date fit specific date.

As data center lack fixVersion iteration I searched and find similar case:

[Solved: Jira Automation - Get the next unreleased version ... (atlassian.com)](https://community.atlassian.com/t5/Jira-questions/Jira-Automation-Get-the-next-unreleased-version-by-criteria/qaq-p/2202432?utm_source=atlcomm&utm_medium=email&utm_campaign=mentions_reply&utm_content=topic)

and added condition to code:

{{#if (releaseDate.format("yyyyMMdd").isAfter(PDDdate))}}

but condition seems does not working, there are versions that are earlier and later than PDD so something should be returenr.

Do you have any ide how to make this working or other solution to get one proper version od Data center automation?

{{#issue.project.versions}}

{{#not(archived)}}

{{#not(released)}}

{{#name.startsWith("EIC 1.")}}

{{#exists(releaseDate)}}

{{#exists(startDate)}}

{{#if (releaseDate.format("yyyyMMdd").isAfter(PDDdate))}}

{{id}}-{{releaseDate.format("yyyyMMdd")}}

{{/}} {{/}} {{/}} {{/}} {{/}} {{/}} {{/}}

![Screenshot_5-8-2024_162857.jpeg](/t5/image/serverpage/image-id/340008iA413A538EEC912D3/image-size/large?v=v2&px=999 "Screenshot_5-8-2024_162857.jpeg")

thanks

Michal


Answers:
author: Bill Sheboy
body: Hi [@Micha?](/t5/user/viewprofilepage/user-id/189407)

Short answer: This is not possible using rules with version date filtering for an iterator. If you explain how your variable PPDdate is defined, the community may offer other approaches, such as using JQL or calling the REST API to gather the versions for examination.

For more on why that type of filtering is not possible...

Once rule processing is *inside of a smart value list iterator* such as this:

```
{{#issue.project.versions}} ...inside the iterator... {{/}}
```

It cannot access any data which is not in the versions data. And so your created variable PPDdate is not visible and thus evaluates to null.

If you carefully read that [thread you linked to in your question](https://community.atlassian.com/t5/Jira-questions/Jira-Automation-Get-the-next-unreleased-version-by-criteria/qaq-p/2202432), you will see the workaround for this limitation:

* create a variable which expands all of your version data into a known, delimited format, for example named varVersionData and delimiting the records with "\~\~"
* create a regular expression in another variable to search for the records, for example named varRegExSearch
* use the inline form of iteration with the match() function to find your records, for example:

```
{{varVersionData.split("~~").match(varRegExSearch)}}
```

* use text functions on the result to extract what is needed

**However this will not help for your scenario** as the match() cannot perform that type of date comparison.

Kind regards,  
Bill

comments: author: Micha?
body: thank you [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

PDDdate is variable that containing date taken from customfiled.

When I updated comparison from using variable to direct customfield call I got some version that has no releaseDate as well does not comply previous conditions.

{{#if (releaseDate.isAfter({{issue.customfield_21970}}))}}

So I assume:

1. customfield can be accessed in iterator

2. #if statment does not take previous conditions so I can't use one iterator to select correct version.

I believe I should follow rather [Boldizs?r Vermes](https://community.atlassian.com/t5/user/viewprofilepage/user-id/5089142) solution. So moving step back.

I have a list of versions that meet few conditions.

How can I select one that has earliest 'releaseDate' after date in customfield_21970?

{{#issue.project.versions}}  
{{#not(archived)}}  
{{#not(released)}}  
{{#name.startsWith("EIC 1.")}}  
{{#exists(releaseDate)}}  
{{#exists(startDate)}}  
{{#if (releaseDate.isAfter({{issue.customfield_21970}}))}} //- this return one version   
{{id}}-{{releaseDate}}

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


author: Bill Sheboy
body: As I already described, **the custom field is not "visible" inside of the iterator on versions**. Only data from versions (and lower) is visible.

I do not believe a *greater than date from a custom field* search of version, release dates is possible with an Atlassian Automation rule with Jira Data Center.

If you know the *exact release date* to match, that can be found.

If the date you want is *the maximum (or minimum) from the versions*, that can be found. (This could be refined if rather than using {{issue.project.versions}} a call is made to the the REST API to gather the unreleased versions, in release date order.)


Tags: automation

data-center

fix-version

jira-data-center