How to assign a selected value to a select widget

I am retrieving customers from an external DB and add them in a select widget then one is selected and the data is displayed in widgets on a form.

It works fine for inputs widgets and they easily display what I tell them but antother select widget that lists available titles (Dr., Monsieur, Madame) is not displaying the title value of the selected customer.

Even more, this select widget is stuck on the last value (Madame) in the list and doesn’t allow me to choose any other.

https://drive.google.com/open?id=0B6S5xj9rO8uXa0pUeXllSjNkLUE

I did a test an managed to successfully update a select widget with customer title after selection of a customer in a select widget.

You can download my example (created with version 7.4.1).

Note that I didn’t use “Displayed key” and “Returned key” (didn’t use a map) but simply “Available values” (a simple list). But it should also be fully functional if you are using “Displayed key” and “Returned key”.

I also managed to successfully update the select widget with customer title after selection of a customer in the other select widget.
I finally was able to do it as I previously gave wrong value to the ‘returned key’ and ‘value’ propreties.
For this case, the available values for the title widget were hardcoded in a json variable following the pair “label”:“value” format.

However, I have another case about devices and deviceGroups following quite a similar pattern as the one with the customer and its title.
When a List<data.model.deviceGroup> is used to populate the select (where deviceGroup is not organized following the “label”:“value” pair) the behavior seems different.
The widget is correctly populated with retrieved deviceGroups but doesn’t display the deviceGroup of the selected device
The “displayed key” is “name”.
The “returned key” is empty and even if it is empty, it definitly does update the formInput.device.deviceGroup variable bound to the “value” property of the select widget but it doesnt display the deviceGroup of the selcted device.
The “available values” is bound to List<data.model.deviceGroup>.value wich returns a json array.

Here is a sample of how the List<data.model.deviceGroup>.value ends up and is passed to the widget.
[
{
“persistenceId”: null,
“persistenceVersion”: null,
“enumeration”: 1,
“kind”: 4004,
“code”: null,
“name”: “Imagerie mobile”
},
{
“persistenceId”: null,
“persistenceVersion”: null,
“enumeration”: 2,
“kind”: 4004,
“code”: null,
“name”: “Echographie”
}
]

Just to be sure I correctly understand your use case:

  • You have a Business Object “Device” that have a “DeviceGroup” attribute
  • In a form you want to display a “Device” associated with your process instance
  • Display of the “Device” must include a select widget with currently select value set to the appropriate “DeviceGroup”

Is that correct?

Right that’s it. It is a kind of identical pattern than with the customer and the customer’s title.
But you can figure it out in the device task of the project that you allready downloaded from another thread.

the project can be found there:
https://drive.google.com/open?id=0B6S5xj9rO8uXd2JqVm9MekNUSlk

Actually I have a question regarding your data model.

You use a composition between the Device and the DeviceGroup. Composition means that if you delete the Device you will delete in cascade the DeviceGroup. I’m assuming that this is not what you want and so that aggregation would be more appropriate for your use case. Is that correct?