How to find all the projects using default field configuration?

Jonnada Kiran June 4, 2018

Hello,

How to find all the projects using default field configuration's of a custom field?

Any sort of help is appreciated. 

Thanks,

Kiran.

 

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.fields.ConfigurableField;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.config.FieldConfigScheme;
import com.atlassian.jira.issue.fields.config.manager.FieldConfigSchemeManager;
import com.atlassian.jira.issue.fields.FieldManager;
import com.atlassian.jira.issue.context.ProjectContext;
import com.atlassian.jira.issue.context.JiraContextNode;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
def log = Logger.getLogger("test.connector")
log.setLevel(Level.DEBUG)


CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
FieldConfigSchemeManager fieldConfigSchemeManager = ComponentAccessor.getFieldConfigSchemeManager();
FieldManager fieldManager = ComponentAccessor.getFieldManager();

def customfield = fieldManager.getCustomField("customfield_26238")
def projects_using = customfield.getConfigurationSchemes()
def projects = customfield.getAssociatedProjectObjects()
log.debug(projects_using)
for(int i=0;i<projects_using.size();i++){
log.debug(projects_using[i].getName())
log.debug(projects_using[i]. getAssociatedProjectIds())
}

 

The above is working only for the projects which have their separate context. 

Output:

2018-06-04 20:04:32,038 DEBUG [test.connector]: [com.atlassian.jira.issue.fields.config.FieldConfigSchemeImpl@5174eeeb, com.atlassian.jira.issue.fields.config.FieldConfigSchemeImpl@25f2efc1, com.atlassian.jira.issue.fields.config.FieldConfigSchemeImpl@2d65b11c]

2018-06-04 20:04:32,038 DEBUG [test.connector]: Default Configuration Scheme for 911 Flow Completed?

2018-06-04 20:04:32,038 DEBUG [test.connector]: []

2018-06-04 20:04:32,038 DEBUG [test.connector]: Phone Launches

2018-06-04 20:04:32,038 DEBUG [test.connector]: [21209, 22015]

2018-06-04 20:04:32,038 DEBUG [test.connector]: Kiran Test

2018-06-04 20:04:32,038 DEBUG [test.connector]: [11204]

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events