Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The following example will add You might need to supplement an existing checklist with additional items, this page will demonstrate how to achieve this.

...

To add items, retrieve the custom field value and then add the desired items to it:

Code Block
// Add an item to the Checklist
def ArrayList<ChecklistItem> existingChecklistValue = (ArrayList<ChecklistItem>) issue.getCustomFieldValue(checklistCustomField);
def newItem = checklistCustomFieldType.getSingularObjectFromString('{"name": "item name"}');
newItem.setRank(existingChecklistValue.size() + 1);
existingChecklistValue.add(newItem);

// Update the issue with the new checklist
checklistCustomFieldType.updateValue(checklistCustomField, event.issue, newChecklistValue);

...

Here is a complete example that adds two items to an existing checklist:

...