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

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

mesher23 November 29, 2018

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
mesher23 November 30, 2018

done, thanks

Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 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

mesher23 December 2, 2018

general Kenobi!

TAGS
AUG Leaders

Atlassian Community Events