Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 map value of child node to parent node during issue creation using java

I have a dropdown by name Domain which has values domainA, domainB, domainC.

for each value of domain, for example domainA has child with options component1, component2.

 

Schema info:

"customfield_10110": {
"required": true,
"schema": {
"type": "option-with-child",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect",
"customId": 10110
},
"name": "Domain",
"hasDefaultValue": false,
"operations": [
"set"
],
"allowedValues": [
{
"self": "https:/rest/api/2/customFieldOption/10009",
"value": "domainA",
"id": "10009",
"children": [
{
"self": "https:/rest/api/2/customFieldOption/10042",
"value": "Component1",
"id": "10042"
}
]
}
]
}

 

During the rest call to create issue, i am unable to map value of child to parent using java code. 

i am using below code to map value of child to parent but its not working. can anyone suggest a way to do it.

IssueInputBuilder issueBuilder = new IssueInputBuilder(projectKey, issueTypeID);

if (fieldID.equals("customfield_10110") && issueField.isRequired()) {
try {
// Get allowed value for the required field
String allowedValue = null;
for (Object object : issueField.getAllowedValues()) {
if (object instanceof CustomFieldOption) {
CustomFieldOption cfo = (CustomFieldOption) object;
allowedValue = cfo.getValue();
String id = String.valueOf(cfo.getId());
//set domain name
if(allowedValue.equalsIgnoreCase("domainA")) {
ComplexIssueInputFieldValue domain = getComplexIssueInputFieldValue(allowedValue,id);
issueBuilder.setFieldValue(fieldID, domain);
//set application name
Iterable<CustomFieldOption> child = cfo.getChildren();
Iterator itr = child.iterator();

while(itr.hasNext()) {
CustomFieldOption childField =(CustomFieldOption) itr.next();
String childValue=childField.getValue();
if(childValue.equalsIgnoreCase("Component1")) {
String childKey = String.valueOf(childField.getId());
ComplexIssueInputFieldValue app = getComplexIssueInputFieldValue(childValue,childKey);
issueBuilder.setFieldValue("customfield_10110", app);
break;
}
}
}

}
}

} catch (Exception ex) {
// Does not have allowed value
issueBuilder.setFieldValue(fieldID, "Test");
}
}

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

254 views 3 20
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