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,382
Community Members
 
Community Events
177
Community Groups

Implementing configurable customfields that respect customfield context

One of my mistakes while developing custom field was not to respect custom field context.

Assume we are implementing a Location custom field type and we want this custom field to be configurable (e.g. countries drop down).

We can design a servlet in which we can select the custom field and pick a country from the drop down. This would work when you create Location types custom fields which do not differ against custom field context.

As an example,

  • define UK Location custom field and select United Kingdom as the location.
  • define USA Location custom field and select United States as the location.

The code would be as below. It is getting customfieldId as the identifier.

LocationConfigItem config = locationService.getLocationConfig(customfieldId);

But if want to have only one location custom field, but differs based on custom field context?

  • define Location custom field
  • add context for UK issue types and select United Kingdom as the location
  • add context for USA issue types and select United States as the location

Our servlet would not work because it can be configured against custom field instead of custom field config context.

So, we should store fieldConfigId for the identifier in order to respect custom field contexts.

LocationConfigItem config = locationService.getLocationConfig(fieldConfigId);

We can obtain fieldConfigId by passing issue object to customfield's getRelevantConfig method as below

Long fieldConfigId = customField.getRelevantConfig(issue).getId();

This way, our configurable custom field type respects custom field contexts which means it can be configured per each context.

I hope I was clear, enjoy!

 

0 comments

Comment

Log in or Sign up to comment
TAGS

Atlassian Community Events