Jira is not aware of all customfields onStart

Hey guys,

I’m having a bit of trouble with a PluginEnabledEvent listener… My plugin requires to check and install some Custom Fields on install - but - It cannot find the first ones (usually one or two) before creating them.

        List<CustomField> cfields = new LinkedList<CustomField>();
        for (CustomFieldInfo customFieldInfo : customFieldNames) {
            try {
                Collection<CustomField> customFields = customFieldManager.getCustomFieldObjectsByName(customFieldInfo.name);
                if (customFields.isEmpty()){ // I'm getting a true value here for first fields...
                  // creates the custom field... causing duplicates sometimes
            } catch (Exception ex) {

I’ve implemented the Listener just as suggested by

Even so, I had to implement a workaround to remove the duplicates afterwards - solution works as intended, but I may be missing something important here on dealing with CustomFieldManager.

Any hints on what I’m missing out?

Thanks in advance