Since getCustomFieldObjectByName is now deprecated, getCustomFieldObject (either long or string) has to be used. I'm in a situation where I need to convert many custom field names into their IDs. One way I though of doing it was creating a Map where each custom field name is matched with its ID, however I feel that is a tedious way of doing things. Is there a way to convert the name of a custom field to its ID? I know there's a way to convert ID into name, but the reverse does not seem to exist unless I've missed something?
You can use getCustomFieldObjectsByName(String customFieldName)
. It returns a Collection of Custom Fields.
Ok, so I've tried that and added .iterator().next() to it, so now it looks like what I have below
customFieldManager.getCustomFieldObjectsByName(customFieldName).iterator().next()
Would this retrieve only the first customField listed in the collection, or would it go through the whole collection? I've checked and there shouldn't be any custom fields in the Jira instance I'm administering that have the same names, therefore there should only be one custom field in the collection.
I've tested the plugin in Jira, but I got this as an error, java.util.NoSuchElementException . Does this mean that the collection was empty from the start? Or that it looped through the collection and then encountered an error because it tried to iterate an empty collection?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It means that the collection was empty. There is no custom field with the name, which you set for the customFieldName variable. You should check your Collection for empty collection or check if it hasNext()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.