Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy the Sprint Name into another field

Gregory Demotchkine
Contributor
December 4, 2013

Business Need: I need to order the issues by sprints, something which JQL (unbelievable!) does not yet support.

Workaround : I want to copy the sprint name into a calculated field. (and hopefully jql will allow me to order by this field) .

Any ideas how to do this in the simplest way possible ? Custom addins like Jira Misc Custom Fields or Script runner ?

Any help with how to configure the syntax will be greatly appreciated!

2 comments

Comment

Log in or Sign up to comment
Gregory Demotchkine
Contributor
December 4, 2013

I'ved tried doing this with Misc Custom Fields addin

I'm getting:

[com.atlassian.greenhopper.service.sprint.Sprint@f39332[rapidViewId=1,state=ACTIVE,name=ITER12,startDate=2013-12-02T10:56:00.000+01:00,endDate=2013-12-20T10:56:00.000+01:00,completeDate=,id=9]]

is there any way to configure the formula to only return me the value between "name=' and ",Startdate" I could use (0,0) but i cannot say for certain what will be a standard length for all sprint names

David _old account_
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.
December 8, 2013

The formula is actually returning a Sprint object, which is then automatically converted (by Java) into a String by its toString() method.

So if you want just the name, you should call getName() on the object.

Like Moriah Chandler likes this
Gregory Demotchkine
Contributor
December 8, 2013

Thanks!

I've tried the following:

<!-- @@Formula: issue.get("customfield_10500").getName() -->

The error I'm geting in jira.log:

[innovalog.jmcf.fields.CalculatedTextField] CalculatedTextField: error evaluating formula: Sourced file: inline evaluation of: `` issue.get("customfield_10500").getName() ;'' : Error in method invocation: Method getName() not found in class'java.util.ArrayList'

David _old account_
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.
December 8, 2013

You first need to get the first version, because fixVersion is a multi-valued field:

issue.get("customfield_10500").iterator().next().getName()

Of course, you should protect this code against errors (such as if issue.get("customfield_10500").isEmpty())

Gregory Demotchkine
Contributor
December 9, 2013

Great! that worked! and to use numerical sorting, I switch to the Calculated Number Field and changed the formula to issue.get("customfield_10500").iterator().next().getId()

and it works, big PM Headache solved, thanks David!

Moriah Chandler
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.
March 18, 2014

Thank you both for this answer - it is so simple and works!

TAGS
AUG Leaders

Atlassian Community Events