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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across Jira Cloud instance.   📢 Get y...

39 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you