Scripted date field issue Edited

I'm trying to show the release date associated with a fix version on issues assigned to that fix version. I've created a scripted field, set it to the Absolute Date Time template, and added this script, based on the answer here. Oddly, if I set it to a text field, it does display a date. 

enableCache = {-> false}
def version = issue.getFixVersions()
if(version) {
return version.first().getReleaseDate().format("dd/MMM/yyy");
}
else {
return null;
}

 

I've also tried this

Date releaseDate = null
issue.fixVersions?.each{releaseDate = it.releaseDate}
return releaseDate

based on the answer here.

Regardless of which code I use, when I view an issue with a fixVersion set (either by using the Preview button, or actually saving the changes and opening an issue), instead of a date, this is what shows:

$datePickerFormatter.format($value)

What am I doing wrong? This is my first attempt at using scripted fields. If this isn't the purpose of the Absolute Date Time template, what is that used for?

 

We're on Jira 7.1.1 and ScriptRunner 5.0.11.

1 answer

Hi Esther,

Can I ask you what kind of searcher you used for the scripted field ?

Searcher: Date Time Range picker
Template: Date Time Picker

And for the script try

enableCache = {-> false}
issue.getFixVersions() ? new Date(issue.getFixVersions().first().getReleaseDate().time) : null

Please let me know if this does the trick 

Regards, Thanos

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 11, 2018 in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

3,662 views 6 6
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you