Hi All.
I am on jira server, using Scriptrunner-behaviours and checklist for jira addon on my environment.
We need dynamic checklist which means checklist items changes based drop-down value selection.
single select drop-down field selectchecklist has two values a and 1.
I have create check list field checklistA and deleted options from it to make it empty.
when a is selected checklistA should have three checkitems a, b and c and when 1 is selected checklistA should have three checkitems 1,2 and 3.
I have created following script but I am not sure how to set the value in behaviours.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def cf = customFieldManager.getCustomFieldObjectByName("checklist_a");
def cfConfig = cf.getRelevantConfig(underlyingIssue)
def cfType = cf.getCustomFieldType()
def listSelectChecklist = (String) getFieldById("customfield_13202").value
def checklistA = getFieldById("customfield_13200")
def desc = getFieldById("description")
log.warn("Outside condition")
if (listSelectChecklist == "1") {
log.warn("inside selection")
def item1 = cfType.getSingularObjectFromString('{"name" : "My Checklist Item 1", "checked" : true, "mandatory" : false}')
def item2 = cfType.getSingularObjectFromString('{"name" : "My Checklist Item 2", "checked" : true, "mandatory" : false}')
def allItems = new ArrayList<Object>();
allItems.add(item1);
allItems.add(item2);
checklistA.setFieldOptions(allItems)
}else if (listSelectChecklist == "a") {
def item1 = cfType.getSingularObjectFromString('{"name" : "My Checklist Item a", "checked" : true, "mandatory" : false}')
def item2 = cfType.getSingularObjectFromString('{"name" : "My Checklist Item b", "checked" : true, "mandatory" : false}')
def allItems = new ArrayList<Object>();
allItems.add(item1);
allItems.add(item2);
checklistA.setFieldOptions(allItems)}
Following is the behaviours setting capture:
This is achieved using script listener rather than behaviours. I have used Issue created and updated events for my project for following filter.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.issueManager
def issue = issueManager.getIssueObject(event.issue.key)
IssueService issueService = ComponentAccessor.getIssueService()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def CustomField listSelectChecklist = customFieldManager.getCustomFieldObject("customfield_13202")
def CustomField checkListField = customFieldManager.getCustomFieldObject("customfield_13200")
def cfType = checkListField.getCustomFieldType()
def listSelectChecklistValue = (String) issue.getCustomFieldValue(listSelectChecklist)
log.warn("Outside condition list selction value = " +listSelectChecklistValue )
if (listSelectChecklistValue == "1") {
log.warn("inside selection")
def item1 = cfType.getSingularObjectFromString('{"name" : "My Checklist Item 1", "checked" : false, "mandatory" : false}')
def item2 = cfType.getSingularObjectFromString('{"name" : "My Checklist Item 2", "checked" : false, "mandatory" : false}')
def allItems = new ArrayList<Object>();
allItems.add(item1);
allItems.add(item2);
issue.setCustomFieldValue(checkListField,allItems)
}else if (listSelectChecklistValue == "a") {
def item1 = cfType.getSingularObjectFromString('{"name" : "My Checklist Item a", "checked" : false, "mandatory" : false}')
def item2 = cfType.getSingularObjectFromString('{"name" : "My Checklist Item b", "checked" : false, "mandatory" : false}')
def allItems = new ArrayList<Object>();
allItems.add(item1);
allItems.add(item2);
issue.setCustomFieldValue(checkListField,allItems)
}
ComponentAccessor.issueManager.updateIssue(currentUser, issue, com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH, false);
@[deleted]
Is there a way to achieve the same outcome without having to code it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can reach out to checklist support and provide them detailed information and they can help you out. the guys are really awesome.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.