You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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!