...
Here is a complete example using the Issue Manager:
Code Block | ||
---|---|---|
| ||
import com.onresolve.scriptrunner.runner.customisers.WithPlugin; import com.atlassian.jira.event.type.EventDispatchOption; import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.MutableIssue; @WithPlugin("com.okapya.jira.checklist") import com.okapya.jira.customfields.*; // Retrieve the Custom Field Type for the Checklist Custom Field def customFieldManager = ComponentAccessor.getCustomFieldManager(); def checklistCustomField = customFieldManager.getCustomFieldObject("customfield_10013"); def checklistCustomFieldType = (ChecklistCFType) checklistCustomField.getCustomFieldType(); // Check all items def issue = (MutableIssue) event.issue; def ArrayList<ChecklistItem> existingChecklistValue = (ArrayList<ChecklistItem>) issue.getCustomFieldValue(checklistCustomField); for (ChecklistItem item : existingChecklistValue) { item.setChecked(true); } // Update the issue with the checklist def issueManager = ComponentAccessor.getIssueManager(); issue.setCustomFieldValue(checklistCustomField, existingChecklistValue.toList()); issueManager.updateIssue(event.user, issue, EventDispatchOption.ISSUE_UPDATED, false); |