Hi everyone.
I have an UI form with a select widget with various options. I want to obtain the item user selects and return it so I am able to use it on the BPM side. In the UI form setting, I populate the select widget with a JSON string such as
[
{"id": 1, "label": "John", "surname": "Smith", "value": "45"},
{"id": 2, "label": "Mark", "surname": "Clark", "value": "21"}
]
I would like to return the entry according to the option selected in the widget ( the displayed key is the label and returned key is the id). How to set the formOutput correctly? More precisely, how to access the select widget and get the selected item?
My bigger picture: I populate the widget with the values from an external DB, the user chooses a value and in the BPM I want to process the selected value without the need to query the external DB with the id the user selected to fetch the remaining field (if this is possible).
Thanks in advance.
Best
Hi,
Yes you can definitely do what you describe.
Here is how I would do it.
First, let’s assume you have the data in a json variable called: selectData.
Then you will configure your Select widget this way:
- Available values: Choose the variable selectData
- Displayed Key: Enter the value ‘label’
- Leave Returned Key empty
- Value: Enter an attribute of formOutput, by example: ‘formOutput.selectValue’
Cheers
Hi and thank for the answer.
My issue is that I created the widget on the UI only so the formOutput variable does not return anything right now. I know I need to add a property that points to the selected value of my Select widget but how do I do that?
EDIT
Now I got it: I thought I first add to map the selected value as a property in the formOutput variable but that is not necessary as setting the value as formOutput.propertyX automatically creates propertyX in the formOutput variable! Thanks for the clarification!
Best
Hi again.
I’m now missing the BPM part. Given that on click on submit the propertyX is send as part of the POST request, how can I fetch this property (or in general, the data sent with the POST request) in the BPM? I do not have any variable defined in the contract as I created the select widget directly in the UI and populated it using the external API.
I believe I should create a variable in the BPM and define an operation that assign the data from the UI that I want to my variable using a groovy script. If this would be the right approach to follow, is there an example of how to fetch a variable (e.g. propertyX) sent with a POST request from the UI using a groovy script?
Thanks (again) in advance.
Best