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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,467,726
Community Members
 
Community Events
177
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

1 vote
Answer 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

Atlassian Community Events