Hi All,
How to change the description of a field for a particular field configuration using groovy?
I have written the below script. It is not throwing any errors and it's not changing the description too.
Code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager
import com.atlassian.jira.issue.fields.layout.field.FieldConfigurationScheme
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItemImpl.Builder
def log = Logger.getLogger("test.connector")
log.setLevel(Level.DEBUG)
FieldLayoutManager fieldLayoutManager = ComponentAccessor.getComponent(FieldLayoutManager);
def scheme = fieldLayoutManager.getEditableDefaultFieldLayout();
def field = scheme.getFieldLayoutItem("customfield_10000");
scheme.setDescription(field,"new desc");
log.debug(scheme.getName());
Hello @Kiran Jonnada
To change field description via groovy you should use customFieldManger, like this
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObjectByName("CustomField name")
customFieldManager.updateCustomField(customField.getIdAsLong(), customField.getName(), "Some test description", customField.getCustomFieldSearcher())
Hello @Kiran Jonnada , I have the same problem to resolve, some 40 custom fields in multiple field configurations. Can you please let me know if you have solved your problem and the approach?
If I follow Mark Markov's note, only default field configuration is changed.
Thank you
with warm regards
ramki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The original post is about the field description in a field configuration. The first reply was about changing the custom field description, which is related but different
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And I think that you can't modify the default field configuration in groovy?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Matt Doar
I had a requirement for this and @Kiran Jonnada script is only missing a line to write the changes.
fieldLayoutManager.storeEditableFieldLayout(scheme)
Complete code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager
import com.atlassian.jira.issue.fields.layout.field.FieldConfigurationScheme
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItemImpl.Builder
def log = Logger.getLogger("test.connector")
log.setLevel(Level.DEBUG)
FieldLayoutManager fieldLayoutManager = ComponentAccessor.getComponent(FieldLayoutManager);
def scheme = fieldLayoutManager.getEditableDefaultFieldLayout();
def field = scheme.getFieldLayoutItem("customfield_10000");
scheme.setDescription(field,"new desc");
log.debug(scheme.getName());
fieldLayoutManager.storeEditableFieldLayout(scheme)
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.