Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jechlin-adaptavist/ec8ae1ccfa015d061a63258b4ca9ea94 to your computer and use it in GitHub Desktop.
Save jechlin-adaptavist/ec8ae1ccfa015d061a63258b4ca9ea94 to your computer and use it in GitHub Desktop.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager
import org.ofbiz.core.entity.DelegatorInterface
import org.ofbiz.core.entity.EntityExpr
import org.ofbiz.core.entity.EntityOperator
def delegatorInterface = ComponentAccessor.getComponent(DelegatorInterface)
def customFieldManager = ComponentAccessor.customFieldManager
def fieldLayoutManager = ComponentAccessor.getComponent(FieldLayoutManager)
def replacementFieldTypes = [
'com.onresolve.jira.groovy.groovyrunner:hideable-textfield': 'com.atlassian.jira.plugin.system.customfieldtypes:textfield',
'com.onresolve.jira.groovy.groovyrunner:hideable-textarea' : 'com.atlassian.jira.plugin.system.customfieldtypes:textarea',
]
delegatorInterface.findByOr('CustomField', replacementFieldTypes.keySet().collect {
new EntityExpr('customfieldtypekey', EntityOperator.EQUALS, it)
}).each {
def replacementType = replacementFieldTypes[it.getString('customfieldtypekey')]
log.warn ("Converting '${it.getString('name')}' to $replacementType.")
it.put('customfieldtypekey', replacementType)
delegatorInterface.store(it, true)
}
fieldLayoutManager.refresh()
customFieldManager.clear()
"Fields converted"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment