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

Sergey L August 8, 2013
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 for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 8, 2013

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

1 vote
Sergey L August 8, 2013
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)


Tom Jackson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 15, 2014

Do you know if this still works in Jira 6.1.7?

Joe Jadamec November 25, 2017

It worked for me in Jira 7.2.9

TAGS
AUG Leaders

Atlassian Community Events