I am looking for a way to list / iterate through all the 'Field Configurations' which are displayed on the screen: https://jira.***.com/secure/admin/ViewFieldLayouts.jspa
This needs to be regardless of Project or 'Field Configuration Scheme'
Once i can do that, then the intention is to go through each and make adjustments as required.
You should be able to use the getEditableFieldLayouts() method to get all your layouts.
import com.atlassian.jira.component.ComponentAccessor
ComponentAccessor.fieldLayoutManager.editableFieldLayouts.collect{"$it.id: $it.name"}.join('<br>')
As far as I know, you can't directly get all field configurations without a project or field config layout. To list or iterate through all field configurations, you'd typically need to go through the schemes and then get the configurations associated with them.
You can navigate through the projects, field configuration schemes, and field configurations. Here’s an approach which might help:
Here is a code you can start with:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager
import com.atlassian.jira.issue.fields.layout.field.FieldLayout
ProjectManager projectManager = ComponentAccessor.getProjectManager()
FieldLayoutManager fieldLayoutManager = ComponentAccessor.getFieldLayoutManager()
// List to hold all unique field configurations
Set<FieldLayout> allFieldConfigs = new HashSet<>()
// provide issue type ids to retrieve field configurations for
Collection<String> allIssueTypeIds = ... //
// Iterate through all projects
projectManager.getProjectObjects().each { project ->
// Get the Field Configuration Scheme for the project
def fieldConfigScheme = fieldLayoutManager.getFieldConfigurationScheme(project)
fieldConfigScheme.getAllFieldLayoutIds(allIssueTypeIds).each { fieldLayoutId ->
// Get the FieldLayout (Field Configuration)
FieldLayout fieldLayout = fieldLayoutManager.getFieldLayout(fieldLayoutId)
allFieldConfigs.add(fieldLayout)
}
}
// Now you have all field configurations
allFieldConfigs.each { fieldLayout ->
log.info "Field Configuration Name: ${fieldLayout.name}"
}
I hope it helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.