How to get date from fixed version and copy to specific attribute?

Suresh September 6, 2011

Hi All,

I have added filed like solution available date filed

The thing is automatically set everytime the ticket is edited based on the earliest date of the field "fix version".

Take into account that fix version is a multiple choice field, so we would need to choose the earliest of them.

Thank in Advance.

suresh.

3 answers

1 accepted

1 vote
Answer accepted
J Thomas
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 6, 2011

You could write yourself a new calculated custom field (instructions here) and put code in the getValueFromIssue method to loop through your issue's fix versions to get the earliest release date.

Calculated fields are automatically recalculated every time the issue is updated.

Suresh September 7, 2011

So i need to develope plug-in.Once i have done calculated custome filed i have to add the custome fileds to corresponding screen.

Is it correct?

Do you have any sample snipts for this so the that i can fallow(logic inside getValueFromIssue method)

B'coz I am to the JIRA API.

thanks

0 votes
Jozsef Frigo _TSM_ January 22, 2019

We use the Jira Workflow Toolbox add-on that has a Calculated Date-Time field custom field type. The configuration expression for this custom field is: min(releaseDates(%{Fixed versions}))

0 votes
J Thomas
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2011

That's correct.

You've looked at the link I gave? It contains links to pages explaining how to set up your plugin development environment. The 'Last commented user calculated field' example is close to what you need except you'll have to replace the comment logic with your earliest fix version release date logic.

See the JIRA API for details of the available methods that you could use. The Issue and Version classes are the ones you'll need - look at Issue.getVersions() and Version.getReleaseDate().

Suresh September 11, 2011

Yes i have seen and i have done plug-in

In the getValueFromIssue method i am getting fix version from issue.

1.But how to get the release date (from that how get instance to the version Interface so that i ll call release date).

2.Once i ll get the release date How i can set in the vm file

in method getValueFromIssue returns "releaseDate"

and vm file value="$releaseDate" Is it ok???

<input type="text" name="Sloution available Date" value="${ReleaseDate}"/>

thanks.

J Thomas
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 11, 2011

You want getValueFromIssue() to return the earliest release date for the issue's selected versions not the fix version otherwise your custom field will display the fix version not the earliest release date.

So in getValueFromIssue() get all the issue's selected versions and check each one in turn to see what its release date is, and return the earliest one.

I've already told you how to get the release date for each version: Version.getReleaseDate(). You shouldn't need to mess about creating velocity templates - just use the same ones that the JIRA date custom fields use eg

<resource type="velocity" name="column-view" location="templates/plugins/fields/view/view-datetime.vm"/>
<resource type="velocity" name="xml" location="templates/plugins/fields/xml/xml-date.vm"/>

Suresh September 12, 2011

There is no method in issue object like getVersions() it has only getFixVersions() and getAffectedVersion() methods for version related.

So how to get issue's selected versions.

And also where should i get vm files like view-datetime.vm and xml-date.vm

Please Helpout this. thanks

Suresh September 13, 2011

ComponentManager componentManager = ComponentManager.getInstance();

List<Version> versions = componentManager.getVersionManager().getVersions(issue.getProjectObject().getId());

Iterator it = versions.iterator();

for (inti = 0; i < versions.size(); i++) {if(it.hasNext()){

System.out.println(it.next());

I am getting issue version in to the list then how to get release date from version

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events