Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,601
Community Members
 
Community Events
176
Community Groups

Set options on select list based on chosen options

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!

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events