Field configuration defines behavior of all standart (system) fields and custom fields available in JIRA installation.
Each field in field configuration has:
Field configurations allow to make configurations of fields for projects to have different behaviour in these projects.
Sometimes a field should have the same behaviour in all projects, but going through all of them manually is uncomfortable process. So it can be automated by using JIRA API. The example is changing description of a field for all projects.
Task: change the description in a custom field.
Solution: To change the description of the custom field we need to get a custom field object, change the description and update this object.
CustomFieldManager fieldManager = ComponentAccessor.getCustomFieldManager();
CustomField customField = fieldManager.getCustomFieldObjectByName("My Field");
customField.setDescription("New description");
fieldManager.updateCustomField(customField);
But this works only if the field is not linked to the custom Field Configurations.
To change the description of a custom field in Default Field Configuration:
EditableDefaultFieldLayout defaultFieldConfiguration =
ComponentAccessor.getFieldLayoutManager().getEditableDefaultFieldLayout();
List<FieldLayoutItem> fields = defaultFieldConfiguration.getFieldLayoutItems();
for (FieldLayoutItem field : fields) {
if (item.getOrderableField().getId().equals(customField.getId())) {
defaultFieldConfiguration.setDescription(field, "New description");
}
}
ComponentAccessor.getFieldLayoutManager().storeEditableDefaultFieldLayout(layout);
To change the description of a custom field in all custom Field Configurations:
List<EditableFieldLayout> fieldConfigurations =
ComponentAccessor.getFieldLayoutManager().getEditableFieldLayouts();
for (EditableFieldLayout fieldConfiguration : fieldConfigurations) {
List<FieldLayoutItem> fields = fieldConfiguration.getFieldLayoutItems();
for (FieldLayoutItem field : fields) {
if (field .getOrderableField().getId().equals(customField .getId())) {
fieldConfiguration.setDescription(field, "New description");
}
}
ComponentAccessor.getFieldLayoutManager().storeEditableFieldLayout(fieldConfiguration);
}
In this way fields can be managed.
Kategorien
Schlagworte
Favoriteneinträge
Getting an e-Commerce website online might sound like a huge undertaking,...
WebView displays web pages. But we are interested not only in web-content...
Google Maps is a very famous and helpful service, which firmly entrenched...
RSpec is an integral part of Test Drive Development (TDD) and its main id...
When developing a web application that extensively works with user input ...
Field configuration defines behavior of all standart (system) fields and ...
As you might have already heard, the latest stuff for upgrading rails was...