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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

0 votes
Answer accepted

done, thanks

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!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Statuspage

New feature: Slack notifications for Statuspage

We're excited to announce the release of a long-requested feature on Statuspage. Now visitors to your status page can subscribe to get notified in Slack when you report an incident or maintenance. Th...

67 views 0 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you