Hi Community, we recently started using "Checklist for Jira" from Okapya. I found a listener script from their documentation that can add a checklist template to an issue. I created a template and added the option "Account created", "Disk assigned" "Phone number assigned" "Laptop assigned" etc. I tested it's working fine. However, I would like to display the list of options based on component selection. For example, if a user selects the component "Onboarding" then should display a template else it should be an empty checklist where the user can create their own checklist option. How can add a condition to associate the template with a component?
import com.onresolve.scriptrunner.runner.customisers.WithPlugin;
import com.atlassian.jira.component.ComponentAccessor;
@WithPlugin("com.okapya.jira.checklist")
import com.okapya.jira.customfields.*;
import com.okapya.jira.customfields.configuration.*;
def issue = event.issue;
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def checklistField = customFieldManager.getCustomFieldObject("customfield_16200");
def checklistCFType = (ChecklistCFType) checklistField.getCustomFieldType();
def templateId = 1;
Template template = checklistCFType.templatesManager.getTemplate(templateId);
Collection<ChecklistItem> templateItems = ChecklistSerializer.deserializeChecklist(template.getItemsJson());
Collection<ChecklistItem> items = (Collection<ChecklistItem>) checklistCFType.getValueFromIssue(checklistField, issue);
items.addAll(templateItems);
checklistCFType.updateValue(checklistField, issue, items);
Thank you for your help!