Hello! I have a custom field of type cascading select. I know how to set the value of the parent object, but I’m stuck on trying to set the child option because I can’t figure out what custom field id value to use.
See my code below. This works great for getting and setting the parent object. How do I set the child object programmatically? Please help!!! Thanks in advance.
Collection<CustomField> cfColl = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName(Constants.NAME_FIELD);
long childfieldID = 0;
if (cfColl != null && !cfColl.isEmpty() && cfColl.size()==1) {
CustomField cf = cfColl.iterator().next();
Options parentOptionObj = ComponentAccessor.getOptionsManager().getOptions(cf.getConfigurationSchemes().listIterator().next().getOneAndOnlyConfig());
String childOptionID = "";
String parentOptionID = "";
for (int i = 0; i < parentOptionObj.size(); i++) {
Option o = parentOptionObj.get(i);
if (o.getValue().equalsIgnoreCase(Constants.NAME_DEFAULT)) {
parentOptionID = String.valueOf(o.getOptionId());
Option childOption = parentOptionObj.getOptionForValue(messageDTO.getCarrier(), o.getOptionId());
if (childOption != null) {
childOptionID = String.valueOf(childOption.getOptionId());
}
break;
}
}
if (!parentOptionID.isEmpty() && !childOptionID.isEmpty()) {
issueParams.addCustomFieldValue(cf.getIdAsLong(), parentOptionID);
issueParams.addCustomFieldValue(**????**, childOptionID);
}