You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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,
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?
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!