Customfield getOptions method returns null

I'm creating a MultipleCustomFieldType type, is working ok, but I'm trying to get the options of the customfield with the method getOptions(String key, FieldConfig config, JiraContextNode contextNode) the same way that the class 'EditCustomFieldOptions' of JIRA does, in that class they used this to get the options:

'options = getCustomField().getOptions(selectedParentOptionId != null ? selectedParentOptionId.toString() : null, getFieldConfig(), null);'

As you can see, they used the method getOptions of a customfield with the associated fieldConfig and a JiraContextNode null, I'm doing the same thing in my method (in a class that extends 'AbstractEditConfigurationItemAction', same class that 'EditCustomFieldOptions' extends ), but I always get a null value for the options, somebody knows why? And yes, the associated field has options configured.

Thank you for your reply.

1 answer

I think, this code would be useful for you

CustomField cf = ComponentManager.getInstance().getCustomFieldManager()
            .getCustomFieldObject(getCfid());

            cftype = CFType.STANDARD_OPTION_SELECT;
            FieldConfigScheme scheme = Utils.getSchemeObjectForContext(cf);
            @SuppressWarnings("rawtypes")
            Map configs = scheme.getConfigsByConfig();
            if (configs != null && !configs.isEmpty())
            {
                Set<Object> configsKeys = configs.keySet();
                for (Object conf : configsKeys)
                {
                    if (conf instanceof FieldConfig)
                    {
                        Options options = optionsManager
                            .getOptions((FieldConfig) conf);
                        if (options != null)
                        {
                            if (cfValues == null)
                            {
                                cfValues = new LinkedHashMap<Option, Object>(
                                    options.size());
                            }
                            for (int i = 0; i < options.size(); i++)
                            {
                                Option option = options.get(i);
                                cfValues.put(option, null);
                            }
                        }
                    }
                }
            }

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

172 views 1 17
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you