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.
This can be accomplished fairly trivially with a scripted field in ScriptRunner.
enableCache = {-> false}
def version = issue.getFixVersions()
version.first().getReleaseDate().format("dd/MMM/yyy")
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.
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.
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?
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Continue discussion for this question here:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ron,
Have you taken a look at this page: https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/postfunctions/set-issue-attributes.html
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()
version.first().getReleaseDate().format("dd/MMM/yyy")
Looking forward to your response.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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()
version.first().getReleaseDate()
I get this:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.