It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Update Custom Field Value with Version Release Date

Ron L Aug 14, 2017

Hello, I'm currently using JIRA Misc Custom Fields to automatically set a custom field with the Version release date.  This works well except for the fact that the issue isn't re-indexed until the issue has been actually updated and the cache cleared.  

Can I use script-runner to get around this at all either by using its custom field or adding a listener on Version release date change to update all linked tickets?  

My goal would be to have this custom field "Release Date" updated whenever an issue's fixVersion is set OR the existing fixVersion's Release Date is udated and have it immediately re-indexed so that the new value can be queried.

1 answer

1 accepted

1 vote
Answer accepted
Joshua Yamdogo [Adaptavist] Community Leader Aug 15, 2017

This can be accomplished fairly trivially with a scripted field in ScriptRunner.

enableCache = {-> false}
def version = issue.getFixVersions()

This will display the release date for the Version, assuming you only have one Version set for the issue. It will automatically update if someone edits the Version release date or changes the Version to another one.

Screen Shot 2017-08-15 at 11.34.37 AM.png

You may want to edit the format for how the date is displayed. You might need to change the searcher/template for the script field if you plan to run JQL queries against it, but that's something you'll have to play around with.

David Fischer [Innovalog] Community Leader Aug 15, 2017

Hi Joshua,

will the value be automatically updated in the JIRA index for all issues that have that Fix Version whenever the version's release date changes? That is, will a search based on that "Release Date" field return all pertinent issues after an update to the version's release date? Without manually triggering a JIRA index update?


Joshua Yamdogo [Adaptavist] Community Leader Aug 15, 2017

From the testing I've done, there doesn't seem to be a problem with the JIRA index. After updating the Version's release date, I did not do any manual reindexing and did not visit any of the issues. Then, I did a JQL search based on Release Date and got the results that I expected with the new Release Date values. 

So, this solution seems to work fine. However, if there were problems with the JIRA index, I think this problem could also be trivially solved using a listener. You can set up a listener that responds to an update of the Version's release date:

Screen Shot 2017-08-15 at 12.21.30 PM.png

Ron L Aug 15, 2017

Hi Joshua,

I was able to use the JQL function releaseDate() to achieve the result.  I have run into an issue where I am unable to use parameters with startOfWeek() in the releaseDate() function.  For example,

fixVersion in releaseDate("after startOfWeek('+1d'))

 Is there a way to do this?  Ultimately, I want to target all release on "This Tuesday", "This Wednesday", etc.

Ron L Aug 20, 2017

Hi Joshua, I'm trying to create a scripted field to store the Release Date based on whether or not there is a fixVersion set.  It's related to the above.

Right now, I'm just trying to test this and have the following code, but it is giving me a "$datePickerFormatter.format($value)" as the result when previewing.  Any ideas why?

return new Date(5000000000000);
Joshua Yamdogo [Adaptavist] Community Leader Aug 21, 2017

Hi Ron,

Have you taken a look at this page:

There's some sample code in there about returning the correct format for a datetime field.

Does the code I supplied above not work for this use case? This code would return the Release Date if there is a fix version set.

enableCache = {-> false}
def version = issue.getFixVersions()

Looking forward to your response.

Ron L Aug 21, 2017

Hi Joshua,

When trying to run your script above and previewing, I get the following in the Result tab: "$datePickerFormatter.format($value)".

I've selected "Absolute Date Time" as the template and have also tried removing the explicit format() call, but still get the above result.

If I select "Text Field" as the template I get "22/Aug/2017".

Joshua Yamdogo [Adaptavist] Community Leader Aug 21, 2017

Hi Ron,

Good observation. You do actually need to remove the format() method. Along with that, you need to change the searcher for the field as well. "Absolute Date Time" is the correct template, but you should go to Admin -> Custom Fields -> Edit field and change the searcher to Date Time Ranger picker.

After doing that and using this script:

enableCache = {-> false}
def version = issue.getFixVersions()

I get this:

Screen Shot 2017-08-21 at 2.53.43 PM.png

Ron L Aug 21, 2017

I made the change to the field to use "Date Time Ranger Picker", but I also had to adapt the solution from another community ticket to get it to work and create a Date object.

The value now shows up, but when attempting to run a JQL query against this column where I'm using >= 2017-08-17, I'm getting issues with 2017-08-16 as a value, which doesn't make sense.

Ron L Aug 21, 2017

On a separate note, is it possible to return just the date or is the formatter on the template always going to return date and time?

Aisha M Feb 26, 2018

@Joshua Yamdogo [Adaptavist] Hi Joshua, I'm fairly new to scriprunner. I am trying to implement the solution you have given above for making the release dates visible with the Fix versions. I just need to know how to accomplish this with the already existing Fix Version field.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Marketplace Apps & Integrations

Demo Den Ep. 4: Continuous Integration with CircleCI & Jira Software

Get ready! Demo Den Episode 4 is coming your way on Tuesday, May 28, 2018 with a Continuous Integration and Delivery special demo. CircleCI Director of Solutions Engineering, Eddie Webb will show us ...

719 views 0 4
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you