Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Extract Version Picker value without brackets []

I have a requirement to extract the value present in a custom field of type "Version Picker" .

If I do this

def releaseVerField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_19641")
def releaseVerFieldValue = issue.getCustomFieldValue(releaseVerField).toString()


I get the output as [7.2] with square brackets. Can someone please advise how to get only the value and ignore the brackets.

1 answer

1 accepted

2 votes
Answer accepted

The [] are a string representation of the fact you've got an list of somethings back from the field, not a string.

Version pickers can hold many options, so your getCustomFieldValue is getting a list (often it'll be a list of one item), then just using "toString" outputs a converted value.

You should not convert it, but iterate over the values and use .getName() or whatever you need to pull out the data you're looking for.  If you can be absolutely sure it's only going to have one value, then just grab the first element from the list.

Hey @Nic Brough _Adaptavist_, I'm looking to do just this. Can you give an example of it. If I use this:


I get the value with brackets. There will always only be one value here, how can I iterate just the value using getName?

If it always has one value only, you can be lazy.  Issue.get("customfield_10002")[0] will fetch the first element of the array.

@Nic Brough _Adaptavist_ Thanks for getting back to me, so I gave Issue.get("customfield_10002")[0] a try and it returns this:

CustomerOrganizationImpl{id=159, name=some company name}

I'm trying to get the name value without brackets. It appears the first element contains both the id and name.

Adding a reply to @David 

As I had the same issue and found a way to achieve it, though i was looking for the ID not the name.



import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;

def value = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10110));

def OrgID =[0]"OrgID:" + OrgID)

return OrgID

Suggest an answer

Log in or Sign up to answer

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you