Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,673
Community Members
 
Community Events
165
Community Groups

Use behavior to display the custom field context description

I would like the ability to read a given Custom field Context (context created for designated projects) and use the description on the context to display in place of the standard description on the field.

I have used the behaviours to display a basic string, but I can not find anything in the Jira developers guide of how to get to this information.

I was hoping for something along the lines of:

getFieldByName("Select List 1").setDescription(CFContext.description)

Thanks,

Jodi

customfield description.pngcustomfield display.pngcustomfield context display.png

1 answer

1 accepted

Hi @Jodi Gornick , you can use this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.fields.config.manager.FieldConfigSchemeManager

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
FieldConfigSchemeManager fieldConfigSchemeManager = ComponentAccessor.getFieldConfigSchemeManager()

CustomField cfSelecList1 = customFieldManager.getCustomFieldObject(10802L) // Change this with the ID of your SelectList CF (XXXXXL)
FieldConfig fieldConfig = cfSelecList1.getRelevantConfig(issueContext)
String description = fieldConfigSchemeManager.getConfigSchemeForFieldConfig(fieldConfig).getDescription()

getFieldById("customfield_10802").setDescription(description) // Change this with the ID of your SelectList CF ("customfield_XXXXX")

 Check the comment on the code to modify it.

Regards!

I had to make a couple changes to make it more versatile, but this put me on the right path so thank you!

Created as a Behaviour with the following code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.config.FieldConfig
import com.atlassian.jira.issue.fields.config.manager.FieldConfigSchemeManager

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
FieldConfigSchemeManager fieldConfigSchemeManager = ComponentAccessor.getFieldConfigSchemeManager()

CustomField cfSelecList1 = customFieldManager.getCustomFieldObject(getFieldChanged())
def formField = getFieldById(getFieldChanged())
FieldConfig fieldConfig = cfSelecList1.getRelevantConfig(issueContext)
String description = fieldConfigSchemeManager.getConfigSchemeForFieldConfig(fieldConfig).getDescription()

formField.setDescription(description)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

217 views 0 6
Join discussion

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