Forums

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

How to get custom field object by name?

Adria Alonso
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.
January 29, 2020 edited

Hello Community,

Jira S 8.6.1

Trying to get customfield by name and no method seems to work.

I see in docs that getCustomFieldObjectByName() is deprecated and now we have to use

getCustomFieldObjectsByName() but its not working.

getCustomFieldObject() + customfield_xxxxx does the job, but I'd like to get them by name, anyone knows a working way?

I want a single customfieldobject no a collection

Thank you

1 answer

0 votes
Payne
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.
January 29, 2020

getCustomFieldObjectsByName() returns a collection, so you need to get one value from it. If you have only one custom field by the name that you specify, then you can simply use getCustomFieldObjectsByName("myField")[0]

Adria Alonso
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.
January 30, 2020 edited

Hello Payne,

First, thank you for your answer.

I am a little lost, since now its working with the single deprecated method

getCustomFieldObjectByName()

But the input parameter needs to be translated

To give you an example:

  • Editting the custom field the name is Relevance
  • In the Custom Field's list its name is in spanish Relevancia

With the translated input string works...

Something has changed or I am missing something.

I've found this:

Method getCustomFieldObjectsByName() doesn't accept the right input parameter 

Thank you in advance 

Adria Alonso
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.
January 30, 2020

@Andreas Ebert  Wrote this

Fyi @Atlassian, I think the bug it due to how the internal cache in CachingCustomFieldManager is initialized: CustomFieldInMemoryStore uses CustomField::getName to populate the Map byName, and since CustomField::getName is locale-dependent on the current user, it uses that user's translated name. Which is wrong. CustomFieldInMemoryStore shouldn't use the translated name. It should use CustomField::getUntranslatedName.

I think its What is happening here.

Suggest an answer

Log in or Sign up to answer
TAGS
Atlassian, Team '25 Europe, Atlassian conference, AI-powered teamwork, Atlassian events, keynote speakers, Barcelona tech conference, Atlassian Williams Racing, Carlos Sainz, Jenson Button, Mike Cannon-Brookes, Anu Bharadwaj, Atlassian Rovo

Atlassian Williams Racing is coming to Team '25 Europe 🏎️

Discover the teamwork and precision behind success on and off the track. See how this high-performing team makes the impossible possible. Be one of the first 100 customers to register for a chance to win 2 tickets to an Atlassian Williams 2026 race.

Register now
AUG Leaders

Atlassian Community Events