Hi.
I have tried to use the behaviours plugin with JIRA 4.4 but for some reason it looks like the values are not parced correct.
import org.ofbiz.core.entity.GenericValue
FormField formComponent = getFieldById(fieldChanged)
FormField formSubcomponent = getFieldByName ("Subcomponent")
Object componentFormValue = formComponent.getFormValue()
List componentIds = []
if (componentFormValue instanceof List) {
componentIds.addAll(componentFormValue as List)
}
else {
// could be an empty string if all components are deselected
if (componentFormValue) {
componentIds.add(componentFormValue)
}
}
Map fieldOptions = [:]
fieldOptions.put ("-1", "None")
for (Long componentId : componentIds) {
try {
Long.parseLong(componentId)
} catch (NumberFormatException e) {
log.error ("Could not get component Id as Long")
return
}
GenericValue component = componentManager.getProjectManager().getComponent(Long.parseLong(componentId))
switch (component?.get("name")) {
case "Component 1" :
fieldOptions.putAll (["Lemons":"Lemons", "Oranges":"Oranges"])
break
case "Component 2" :
fieldOptions.putAll (["Spinach":"Spinach", "Celery":"Celery"])
break
}
}
formSubcomponent.setFieldOptions (fieldOptions)
The problem is that it shows either all values no matter what is the component setting.
It looks like che if is not working as expected. Can someone help ?