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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

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
Published in Marketplace Apps & Integrations

Do Not Lose your Customer’s Trust

Missing deadlines is one of the biggest problems every team lead wants to avoid when dealing with managed services. When the customer contracts your company to help with IT services it is expected th...

24 views 0 0
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