Forums

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

Customfield getOptions method returns null

JPB
Contributor
September 23, 2014

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

0 votes
Dmitry Miroshnichenko
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.
September 24, 2014

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
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events