Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to change description of a field for a particular field configurations using groovy?

Kiran Jonnada October 7, 2018

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());

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2018

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())
Ramakrishnan Srinivasan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 21, 2022

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 

Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 11, 2022

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

Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 11, 2022

And I think that you can't modify the default field configuration in groovy?

Iwan Jones
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 3, 2022

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)
TAGS
AUG Leaders

Atlassian Community Events