Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
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

How to get a string value from a drop down custom field

Hello! The situation is this: I need to output the selected string value from the child's drop-down list to another field. here is the code

<code>

import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.customfields.view.CustomFieldParams
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.customfields.view.CustomFieldParams
import com.atlassian.jira.issue.customfields.impl.CascadingSelectCFType
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.Issue


def IssueManager issueManager = ComponentAccessor.getIssueManager();


def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cfNFeed = customFieldManager.getCustomFieldObject('customfield_12404')
def direction = issue.getCustomFieldValue(cfNFeed)

def v_bus_direction = direction.split(';')[0]
def bus_direction = v_bus_direction.split(':')[1]
def v_work_direction = direction.split(';')[1]
def work_direction = v_work_direction.split(':')[1]
def v_type_work = direction.split(';')[2]
def type_work = v_type_work.split(':')[1]

String parent_new_value = bus_direction.toString() + ": " + work_direction.toString()
String children_new_value = type_work.toString() - "]"

def changeHolder = new DefaultIssueChangeHolder()
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11117")
def fieldConfig = customField.getRelevantConfig(issue)
def parentOption = ComponentAccessor.getOptionsManager().getOptions(fieldConfig)?.find { it.toString() == parent_new_value }
def childOption = ComponentAccessor.getOptionsManager().findByParentId(parentOption.optionId)?.find { children_new_value }

def newValue = [:]
newValue.put(null, parentOption)
newValue.put("1", childOption)
customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), newValue),changeHolder)

</>

All i need is to transfer

 

children_new_value



to view here

newValue.put("1", childOption)

 thanks!image.pngimage.png

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted

done, thanks

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Nov 30, 2018

Hello there,

Please feel free to share with us your solution so that it can help other users in the future!

Regards,
Shannon

general Kenobi!

TAGS
AUG Leaders

Atlassian Community Events