We are adding a for loop in a Behavior to collect the option IDs of a multi-select field.
On Script Console, the for loop works -- it gathers the option IDs and puts it in a list.
However, when added to a Behavior, the for loop breaks the entire behavior. Dx
Has anyone had success with a for loop on Behaviors? For reference here is our behavior:
import com.atlassian.jira.issue.IssueManagerimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.jql.parser.JqlQueryParserimport com.atlassian.jira.issue.search.SearchProviderimport static org.apache.commons.collections.CollectionUtils.*final productLine = "Product Line(s)"if (getBehaviourContextId() == "create-epic-button") {//TestinggetFieldByName("Summary").setFormValue("Testing")// Get some componentsdef jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)def searchProvider = ComponentAccessor.getComponent(SearchProvider)def issueManager = ComponentAccessor.issueManagerdef user = ComponentAccessor.jiraAuthenticationContext.loggedInUserdef optManager = ComponentAccessor.getOptionsManager()//Parent Linkdef parentLink = getFieldByName("Parent Link")def parentLinkValue = parentLink.getValue()def contextIssue = issueManager.getIssueObject(getContextIssueId())parentLink.setFormValue("${contextIssue.key}")//Product Linedef productLineName = ComponentAccessor.customFieldManager.customFieldObjects.findByName(productLine) //Get Objectsdef productLineList = getFieldByName(productLine).getValue() as List //Get Values as Listlog.warn("Product Line List: $productLineList")//Get Product Line Field Configdef productLineConfig = productLineName.getRelevantConfig(contextIssue)log.warn("Product Line Field Configuration: $productLineConfig")//Get Product Line Field Value Optionsdef productLineOptions = optManager.getOptions(productLineConfig)log.warn("Product Line Options: $productLineOptions")def targetValues = []for (i in productLineList) {log.warn "processing $contextIssue value = $i"//Convert i to a string and define it in a variabledef newVal = i.toString()//Get Product Line Option IDdef productLineOptionID = productLineOptions. find { it.value == newVal }log.warn("Product Line Option ID: $productLineOptionID")//Add to targetValues ListtargetValues += productLineOptionID.optionIdlog.warn("Product Line Target Values: $targetValues")getFieldByName("Product Line(s)").setDescription("Woooorrkkkkk")}} else {}
I don't think it's this, but is the user part of the rule for the new level? Can they change the security level to the desired one by editing the issue in the UI?
Are you making other changes to the issue in the script? If so, are they working?
There is no option to run under the context of a specific user, so I assume the post function will run under the current user's context (see attached screenshot to see what it looks like to define this workflow post function).
Also, I tested this as an administrator (full project permissions) and still no luck. I'm completely at a loss. Any help is very much appreciated
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.