This documentation is for version 4.x. For the latest documentation, click here
Modify the items of an existing checklist
A common use case is to modify existing items in a checklist to change some of their properties.
See Checklist Classes and API to see all available checklist item methods.
To modify the items you first need to retrieve the current list of items from the custom field.
def ArrayList<ChecklistItem> existingChecklistValue = (ArrayList<ChecklistItem>) event.issue.getCustomFieldValue(checklistCustomField);
You then loop over the collection and apply the desired changes. For example, you can clear all the statuses from the items.
// Remove statuses of the Checklist
for (ChecklistItem item : existingChecklistValue) {
item.setStatusId("none");
}
Finally, you update the custom field passing it the same collection that was initially extracted from the custom field.
checklistCustomFieldType.updateValue(checklistCustomField, event.issue, existingChecklistValue);
Following is a complete example that can be used to modify a checklist by:
Unchecking all items.
Clearing items with “In Progress” statuses.
Making optional the item “Run all tests”.