You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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]