Quite simple what I'm trying to do, I have an array of field configuration schemes (projectlessFieldConfigSchemes) that I would like to delete. I attempt the code below to remove just the first of the array.
Script for deleting not used Field Configuration Schemes and Field Configurations. Please use responsibly:
import com.atlassian.jira.component.ComponentAccessor
def html = ''
def flm = ComponentAccessor.getFieldLayoutManager()
// Field Configuration Schemes without projects - can be deleted
def schemesToDelete = flm.getFieldLayoutSchemes().findAll{!it.getProjectsUsing()}
html +="Field Configuration Schemes for deletion(count:${schemesToDelete.size()}):"+schemesToDelete*.name+'<br>'
//delete not used schemes
schemesToDelete.each{ scheme ->
// flm.removeFieldLayoutScheme(scheme)
html += "Scheme: ${scheme.name} was deleted<br>"
}
// part 2: deletion of Field Configurations
def layouts = flm.getEditableFieldLayouts()
// Field Configurations without Field Configuration Schemes - can be deleted
def fieldConfigurationsToDelete = layouts.findAll{!flm.getFieldConfigurationSchemes(it)}
html +="Field Configurations for deletion(count:${fieldConfigurationsToDelete.size()}):"+fieldConfigurationsToDelete*.name+'<br>'
//delete not used Field Configurations
fieldConfigurationsToDelete.each{ config ->
//flm.deleteFieldLayout(config)
html += "Config: ${config.name} was deleted<br>"
}
return html
This was a very confusing thread to follow. For anyone seeing this in the future here is the code to delete a set of field configurations by their ID.
import com.atlassian.jira.component.ComponentAccessor
def fieldConfigSchemeMgr = ComponentAccessor.fieldLayoutManager
def layouts = []
for (l in layouts) {
def layout = fieldConfigSchemeMgr.getFieldLayout(l)
fieldConfigSchemeMgr.deleteFieldLayout(layout)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jeremy,
Thanks for this code snippet! Is this to delete a field configuration scheme, or just the field configuration/layout?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can delete the schemes in this way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
fieldConfigSchemeMgr.getFieldConfigScheme will get you the issuetype scheme, while the other gets you the field configuration scheme -> don't know why the naming is so weird in the API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the Atlassian Community!
Immutable objects do not have function calls that change them, so your second try is always going to fail.
In your fist bit of code, I don't think your temp object contains anything.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your interest. So the first bit of code is referring to an array of Field Configuration Schemes that I gathered via the command
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But you're not putting anything into the "temp" variable, unless you've not given us all the code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did not, just put in the lines that led to the error since the full code is quite long and unnecessary. I have gone ahead and simplified the code with the error to be self-contained. FCS 13300 exists. I am certain there is something small I am missing, but can't find any working examples online either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Very interesting development this:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I still would love some insight into this as you would think that the method "getFieldConfigScheme" would return a Field Config Scheme, but I have gotten the code to work with
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am very confused by your postings of partial bits of code, so I am not sure what you would like a pointer to.
But I suspect it would be a part of https://docs.atlassian.com/software/jira/docs/api/9.3.1/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nope, that's the documentation I referred to earlier that was not great, but I have answered the based question for myself and posted the code for others, so I'll go ahead and close the question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.