Versions Compared

Key

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

...

Code Block
languagejava
import com.atlassian.jira.component.ComponentAccessor;

// Retrieve the Custom Field Type for the Checklist Custom Field
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def checklistCustomField = customFieldManager.getCustomFieldObject("customfield_10013");
def checklistCustomFieldType = checklistCustomField.getCustomFieldType();

// Json representation of an item
def itemJson =  '''
{
	"name": "Run all tests",
    "checked": false,
    "statusId": "none",
    "mandatory": false,
    "rank": 0
}
''';

// Create a checklist item
def ChecklistItem newItem = checklistCustomFieldType.getSingularObjectFromString(itemJson);

Utility Method

Info

If you intend to create many items, a good practice is to use an utility method to facilitate creation of a ChecklistItem objects.

...