Versions Compared

Key

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

The Checklist custom field can be programmatically manipulated to extract and modify it’s data. You can use any scripting tool that allows you to access the custom field’s Java based classes but one of the most popular tool for doing this is ScriptRunner which uses groovy scripts.

...

Method Name

Return Value / Description

getId

Long. Unique identifier for the item (returns the Option ID if an Option).

isChecked

Boolean. Indicates if the item is checked.

getName

String. Item name.

getRank

Integer. Indicates the order of the item.

isMandatory

Boolean. Indicates if the item is mandatory.

getStatusId

String. Identifier for the item’s status (none if no status selected).

hasStatus

Boolean. Indicates if a status is present.

getOptionId

Long. Returns the ID of the Option (If applicable, otherwise returns -1).

isOption

Boolean. Indicates if this item is an option (global item).

isDisabled

Boolean. Indicates if the linked option is disabled.

toJson

String. Returns JSON representation of the item.

setRank(Integer rank)

Void. Changes the rank of the item.

setStatusId(String statusId)

Void. Changes the status ID of the item.

setDiscretionary(Boolean discretionary)

Void. Changes the discretionary (not mandatory) state of the item. Setting false means mandatory.

setChecked(Boolean checked)

Void. Changes the checked state of the item.

...

Json Property

Type / Description

id

Number. Unique identifier. This can be ignored when creating items.

optionId

Number. Option Identifier. You only need to provide the Option ID if you want to modify an option.

name

String. Name of the item. This is the only mandatory property in order to create a ChecklistItem.

checked

Boolean. Indicates if the item is checked.

mandatory

Boolean. Indicates if the item is mandatory.

rank

Number. Indicates the order of the item.

statusId

String. Indicates the status identifier of the item. “none” means no status.

...

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

// Get the Checklist value. The issue is taken from inside a Scriptrunner listener
def issue = event.issue;
def ArrayList<ChecklistItem> existingChecklistValue = (ArrayList<ChecklistItem>) issue.getCustomFieldValue(checklistCustomField);

...