Skip to Content

To the 7.0+ 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.PNG

1. Add relevant Data Service to the model. Connect input and output:

2.PNG

2. To the table add a Boolean field in the Define Data dialog:

3.PNG

3. Add a Data Share element with a field to contain the user selections:

8.PNG

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&”;”

4_.PNG

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&”;”,””)

5.PNG

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.

6.PNG

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:

7_.PNG

To the 7.0+ version

Check out the advanced solution in: Pass multiple selected values as a single field – support repetitions.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Ehud Nir Post author

    Recommended enhancement:

    As I mentioned in the document, this solution does not support repetitions. Consider the table:

    Louie
    Huey
    Louie
    Louie
    Dewey

    After several selections we reach the following state for our selections field:

    Louie;Huey;Louie;Louie;

    Now the user deselects one of the Louie entries from the table. The replace() function in the deselect expression replaces each Louie; with an empty string, and we end up with:

    Huey;

    🙁 This is of course a mistake. The back end does not get all the relevant names and the process output is invalid. Tougher still, we might not recognize this elusive bug for some time.

    Next step

    Come up with a solution covering this case as well.

    (0) 

Leave a Reply