Hi,
I have a hierarchy on my project of Stage -> Team assignment, and when you create a team assignment you choose a team allocation (team and sub-team).
I wrote a script runner behavior. when I create a new "team assignment" issue on my project, the script takes all the values of team assignment allocation that have already been created under the stage.
What I want is that in the create screen, on the team allocation field, it will show only the options that were not selected. I managed to create a list of all the option that has been selected, but I don't know how to extract the values, and how to set the "new" option.
Now the list looks like this: [[null: value,1 :value], [null:value,1 :value], [null:value,1 :value]].
and here is the code:
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def issueManager = ComponentAccessor.getIssueManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
if (getActionName() in ["Create Issue", "Create"]) {
FormField parentKey = getFieldById("customfield_11200")//parent key field
def val = parentKey.getValue()
MutableIssue parent = issueManager.getIssueObject(parentKey.getValue())
def childern = []
def childLinkId=10400
issueLinkManager.getInwardLinks(parent.id)
.each { link->
if(link.linkTypeId == childLinkId){
childern.add(link.getSourceObject())
}
}
def ta = []
CustomField teamAssign = customFieldManager.getCustomFieldObject("customfield_10905")//team assign field
childern.each{child ->
MutableIssue childNew = child as MutableIssue;
ta.add(childNew.getCustomFieldValue(teamAssign))
}
ta.unique()
log.warn("team assign: " + ta)
}
Thank you for your help!