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.
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.
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
But you're not putting anything into the "temp" variable, unless you've not given us all the code.
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 can delete the schemes in this way.
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
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.ComponentAccessordef fieldConfigSchemeMgr = ComponentAccessor.fieldLayoutManagerdef layouts = []for (l in layouts) {def layout = fieldConfigSchemeMgr.getFieldLayout(l)fieldConfigSchemeMgr.deleteFieldLayout(layout)}
Jeremy,
Thanks for this code snippet! Is this to delete a field configuration scheme, or just the field configuration/layout?
Discussion helped me to write script for deleting not used Field Configuration Schemes and Field Configurations. Adding as a separate answer
Script for deleting not used Field Configuration Schemes and Field Configurations. Please use responsibly:
import com.atlassian.jira.component.ComponentAccessordef html = ''def flm = ComponentAccessor.getFieldLayoutManager()// Field Configuration Schemes without projects - can be deleteddef schemesToDelete = flm.getFieldLayoutSchemes().findAll{!it.getProjectsUsing()}html +="Field Configuration Schemes for deletion(count:${schemesToDelete.size()}):"+schemesToDelete*.name+'<br>'//delete not used schemesschemesToDelete.each{ scheme -> // flm.removeFieldLayoutScheme(scheme) html += "Scheme: ${scheme.name} was deleted<br>"}// part 2: deletion of Field Configurationsdef layouts = flm.getEditableFieldLayouts()// Field Configurations without Field Configuration Schemes - can be deleteddef fieldConfigurationsToDelete = layouts.findAll{!flm.getFieldConfigurationSchemes(it)}html +="Field Configurations for deletion(count:${fieldConfigurationsToDelete.size()}):"+fieldConfigurationsToDelete*.name+'<br>'//delete not used Field ConfigurationsfieldConfigurationsToDelete.each{ config -> //flm.deleteFieldLayout(config) html += "Config: ${config.name} was deleted<br>"}return html
It looks like you're new here. Sign in or register to get started.