How to copy custom field (Cascading Select) value from parent task to child sub-task

test = parentIssue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10300"))
// test == class java.util.HashMap (Cascading Select custom field)

issueSubTaskParams.addCustomFieldValue(10300, test)


Hi community!

addCustomFieldValue accepts `String` only
So, how to get proper String value from HashMap?

Thanks,
Sergey

2 answers

1 accepted

Comments Closed
This widget could not be displayed.

Hey there,

i use the following

//Gets a reference to the desired custom field -  Cascading Select List
CustomField customField_object = customFieldManager.getCustomFieldObject( customfied_id );

//get the original value in a map Map valueMap = (Map)issue.getCustomFieldValue(customField_object); Option option = (Option)valueMap.get(null); String firstLevelValue = option.getValue(); option = (Option)valueMap.get("1"); String secondLevelValue = option.getValue();
//Create a string value with the values you get from Cascade select lis
String value = firstLevelValue + " - " + secondLevelValue

You can then pass the value string to your desired custom field.

Cheers

This widget could not be displayed.
parent = test.get(null).getGenericValue().id.value.toString()
child = test.get('1').getGenericValue().id.value.toString()
issueSubTaskParams.addCustomFieldValue("customfield_10300", parent)
issueSubTaskParams.addCustomFieldValue("customfield_10300:1", child)


Do you know if this still works in Jira 6.1.7?

It worked for me in Jira 7.2.9

Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

515 views 3 18
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you