This documentation is for version 4.x. For the latest documentation, click here

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

Version 1 Next »

The best way to create a new Checklist Item object is to use the getSingularObjectFromString(String) method of the Custom Field Type.


Retrieve the Custom Field Type and use a JSON representation string to generate a new ChecklistItem.

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();

// Create a new ChecklistItem
def itemJson =  '''
{
	"name": "Run all tests",
    "checked": false,
    "statusId": "none",
    "mandatory": false,
    "rank": 0
}
''';
def ChecklistItem newItem = checklistCustomFieldType.getSingularObjectFromString(itemJson);

We have written an utility method to facilitate creation of a new ChecklistItem object. In many of our examples, we are using this method:

def ChecklistItem createChecklistItem(ChecklistCFType cfType, String name, boolean checked, String status, boolean mandatory, int rank) {
    def itemJson =  """
    {
        "name": "${name}",
        "checked": ${checked ? "true" : "false"},
        "statusId": "${status == null || status == "" ? "none" : status}",
        "mandatory": ${mandatory ? "true" : "false"},
        "rank": ${rank}
    }
    """;
    return cfType.getSingularObjectFromString(itemJson);
}
  • No labels