Pass multiple selected values as a single field – 7.1+ version
A common scenario is for the user to select several entries from a table. In some cases, we need to pass all selections as one Data Field.
An example application might look this way: after pressing Submit and getting the bank list from Service 1, the user selects the bank names to pass to Service 2 (the bottommost Form is added for testing purposes):
1. Add relevant Data Service to the model. Connect input and output:
2. To the table add a Boolean field in the Define Data dialog:
3. Add a Data Share element with a field to contain the user selections:
4. In the Layout Board, add an Assign Action to the check box control: If value is true we add to the selection Field the current value concatenated to ‘;’ as delimiter.
- Condition: =@select==true
- Assigned value: =share1@selection&BANK_LIST@BANK_NAME&”;”
5. Add another Assign Action to the check box Control: If value is false, we replace in the selection Field the current value with an empty string.
- Condition: =@select==false
- Assigned value: =REPLACE(share1@selection,BANK_LIST@BANK_NAME&”;”,””)
Note: This commend removes all occurrences of the value. In case repetitions are relevant the solution should be revised.
Check out the resolution in: Pass multiple selected values as a single field – support repetitions.
6. Add a button on the table to trigger the activation of the second data service.
7. Add the second data service to the model – the one getting the selection result. In this example I used a Service Component model to echo the input.
8. Link the Data Share and the second data service. set the event name of the link to *selection. the * is needed since the event is not coming from the link source – so that it’s a global event listening:
Check out the advanced solution in: Pass multiple selected values as a single field – support repetitions.