Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jechlin-adaptavist/7274b0e5ca085d3819c615b275031eab to your computer and use it in GitHub Desktop.
Save jechlin-adaptavist/7274b0e5ca085d3819c615b275031eab to your computer and use it in GitHub Desktop.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.FieldManager
import com.atlassian.jira.issue.fields.screen.FieldScreenManager
def fieldScreenManager = ComponentAccessor.getComponent(FieldScreenManager)
def fieldManager = ComponentAccessor.getComponent(FieldManager)
// change to false to remove invalid fields
def preview = true
fieldScreenManager.fieldScreens.each { screen ->
screen.tabs.each { tab ->
tab.fieldScreenLayoutItems.findAll { layoutItem ->
!fieldManager.getField(layoutItem.fieldId)
}.each { layoutItem ->
log.warn("Missing field: $layoutItem.fieldId on screen: '$screen.name', tab: '${tab.name}'")
if (!preview) {
tab.removeFieldScreenLayoutItem(layoutItem.position)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment