Jira Automation that performs action X days prior to version release
Asked by Mykhailo Pavliuk:

Hello!

I am working on an automation rule that should create a new issue in a project 5 days prior to version's release date.

I thought it should look like this:

-A scheduled rule that runs every day  
-If condition is met: it returns issues from this project, with a specific component, where difference between today and version release date is 5 days   
-It creates a Task with some pre-populated fields

The only problem here is that "Release date\[Date\]" = startOfDay(5) does not seem to work.

I tried using condition that compares two custom values with this set up:

{{startOfDay.diff(issue.fixVersions.releaseDate.jiraDate}} = 5

But it fails to get requested value and also parses way too many issues.

Perhaps someone had a similar case?

Thank you!


Answers:
author: Mykhailo Pavliuk
body: for those finding this with the same problem, here is a full screenshot of the automation rule:

![Screenshot 2023-10-17 at 15.39.26.png](https://community.atlassian.com/t5/image/serverpage/image-id/286720iECF8DABBA3406942/image-size/large?v=v2&px=999 "Screenshot 2023-10-17 at 15.39.26.png")


author: Bill Sheboy
body: Hi [@Mykhailo Pavliuk](/t5/user/viewprofilepage/user-id/5331415)

Do you always have issues assigned to the next, unreleased version at that 5 day point? The answer will impact how you solve this.

*Yes, the team always has issues assigned...*

* Try using a scheduled trigger, with no JQL
* Then use the Lookup Issues action, with JQL checking for earliestUnreleasedVersion(): <https://support.atlassian.com/jira-software-cloud/docs/jql-functions/#earliestUnreleasedVersion-->
* Using the first issue found in the lookup, perform the date comparison with a condition
* And create the issue if the test passed

*No, the team does not always have issues assigned...*

* Try using a scheduled trigger, with no JQL
* Using the Send Web Request action, call the REST API function to get all of the versions for the project
* Filtering the web response for open versions, use list functions to get the earliest date, and perform the date comparison with a condition
* And create the issue if the test passed

Kind regards,  
Bill

comments: author: Mykhailo Pavliuk
body: hi Bill!

Both are great suggestions. So trick is that we always have issues assigned to fix version that is going to be released, but I have to make sure it is the right one by limiting the search by component, because the project is for mobile development and they have parallel versions for different OS.

I will definitely use scheduled trigger and play around with Lookup to avoid parsing 1,000 issues.

Tim's suggestion to use double if conditions let's me grab it at exact date I need.

Thank you!


author: Bill Sheboy
body: If your Fix Version will ever have more than one entry, using conditions will not work as expected as it will return a list of dates. In that case you may either add smart value, list filtering, or use the max function on the releaseDate in the list of versions.


author: Tim C
body: Hi [@Mykhailo Pavliuk](/t5/user/viewprofilepage/user-id/5331415)

I think you're already quite close to a workable solution.

This condition works fine for me ...

![Screenshot 2023-10-16 154028.png](https://community.atlassian.com/t5/image/serverpage/image-id/286522i709F021276522F55/image-size/large?v=v2&px=999 "Screenshot 2023-10-16 154028.png")

You'll probably also have to add another similar one which is greater than 4 days - so that results found are only for those which are between 4 and 5 days away.

If not, it will continue to find all previous release dates going backwards forever.

![Screenshot 2023-10-16 154348.png](https://community.atlassian.com/t5/image/serverpage/image-id/286524i5D4428042189D060/image-size/large?v=v2&px=999 "Screenshot 2023-10-16 154348.png")

I hope this makes sense and is helpful?

Thanks,

TC.

comments: author: Tim C
body: Hi [@Mykhailo Pavliuk](/t5/user/viewprofilepage/user-id/5331415)

I noticed you just voted for my answer ... please free to "accept" if this has worked - so it marks as answered (and helps others in community find this solution in the future).

Also, it helps raise my profile (kudos points) ?


author: Mykhailo Pavliuk
body: Hi Tim!

Thank you so much for this correction, this condition passes without an error, but it doesn't match an issue that has FixVersion set to version that releases 5 days from now, non October 21st (also tried with 23rd in case it counts business days).

I tested with both startOfDay and now![Screenshot 2023-10-16 at 18.06.16.png](https://community.atlassian.com/t5/image/serverpage/image-id/286532i92EB662D7FA427DC/image-size/large?v=v2&px=999 "Screenshot 2023-10-16 at 18.06.16.png")

Was this different for you?

Thanks!


author: Tim C
body: [@Mykhailo Pavliuk](/t5/user/viewprofilepage/user-id/5331415)

Yeah, it worked fine for me .... please check that the version is definitely set in the ADMSB project with associated release date and that version is assigned to the ADMSB-1 ticket?

Perhaps, use the "log action" event to record your smart values into the audit log to double check what's being found/compared....?

![Screenshot 2023-10-16 161606.png](https://community.atlassian.com/t5/image/serverpage/image-id/286534i6D69A5F38FDC0C54/image-size/large?v=v2&px=999 "Screenshot 2023-10-16 161606.png")


author: Mykhailo Pavliuk
body: hi Tim,

Yeah the issue passes if it is less than now+6 and more than now +4 (because it is equal to now+5) so I just needed to sleep on this :) Thank you!


author: Tim C
body: Hi [@Mykhailo Pavliuk](/t5/user/viewprofilepage/user-id/5331415) - that's great news.

Glad to have helped. Don't forget to accept my answer so gets marked as solved.


author: Mykhailo Pavliuk
body: Current IF condition for the rule that fails:![Screenshot 2023-10-16 at 13.07.16.png](https://community.atlassian.com/t5/image/serverpage/image-id/286475i76537DDB05B914D3/image-size/large?v=v2&px=999 "Screenshot 2023-10-16 at 13.07.16.png")