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!
Tuncay Senturk _Snapbytes_Community Leader
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