Forums

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

Need a misc calculated field that shows Components of an issue as a String

Gareth Beynon July 18, 2017

Hi All,

I've just started using EazyBI and I'm adding some extra fields to it using the MISC custom fields add-in. 

So far so good for most simple things I need, however I am now trying a more complex field to store all Components selected on an issue into a separate custom text field as a comma delimitted string.

I just can't seem to get the right syntax or I'm missing something obvious.

On the EazyBI website I can see this example for Fix Versions:

<!-- @@Formula:
import org.apache.commons.lang.StringUtils;
StringUtils.join(issue.get("fixVersions"), ",");
-->

This works great for that field. I then tried issue.get("components") but that didn't work for me.

Looking through the API knowledge base for Components it seems I need to use issue.getComponents() to return a collection and then .getName() to return the name part of the collection? 

Anyone know a simple way to grab all the names of the selected components and put them into a string? 

Any help is much appreciated!

 

1 answer

1 accepted

1 vote
Answer accepted
Gaston Valente
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.
July 19, 2017

Hi Gareth,

I'm sure there're better and more clean ways, but this should work:

<!-- @@Formula:

import com.atlassian.jira.bc.project.component.ProjectComponent;
import java.lang.StringBuffer;

StringBuffer issueComponents = new StringBuffer();

for(ProjectComponent pc : issue.get("components")){
if(issueComponents.length() > 0) issueComponents.append(",");
issueComponents.append(pc.getName());
}

issueComponents.toString();
-->
Gareth Beynon July 23, 2017

Thanks this works perfectly!

Gaston Valente
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.
July 23, 2017

great!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events