All Collections
Asite AppBuilder
AppBuilder Sample Scripts
Show multiple responses in single view using 'Repeating Table' control
Show multiple responses in single view using 'Repeating Table' control

This is an AppBuilder Sample Script.

Updated over a week ago

When you design forms, you can implement Repeating Tables to create a multiple-response view. You can implement it on any view in your form by making the view a Repeating Table. Help your team work faster and more effectively by seeing responses together, rather than clicking in and out of individual responses on forms.

For some views, you may want to keep multiple responses hidden.

Set Up a Repeating Table in Your Form View

The classic view on forms is single-response, but with a Repeating Table, you can enable a multiple-response view.

Single Response View

Multiple Response View

A multi-response view can streamline how your teams work on forms, so they can work faster without clicking in and out of individual responses.

Below AppBuilder Sample Script will show you how to set up a multi-response view for a form’s Responded View.

AppBuilder Sample Script

As an example, we have a form where we want the person who has requested responses to see them in a single view – a multiple-response view.

Our Response View, the view where the form respondents will fill in their responses, has a Repeating Table field called 'ResponseDetails_RT'.

This repeating table has a single column without any header or footer.

Inside our Repeating Table is a Table field called “ResponseDetails_Table.” This is where we capture responses in fields like User Name, Date Replied, and Response

We also have a Responded View where the details captured in “Response View” display for the teammate who has sent the form, such as an RFI. This is where we want our Repeating Table to provide a multiple-response view.

To do this, we want to create a Repeating Table in Responded View that displays the responses captured in the Repeating Table on Response View. We'll use the drag-and-drop code editor in the “onLoad” event to display the “ResponseDetails_RT” table in the Responded View. The complete code will look like below (Figure 4):

Let’s break it down.

First Code Block for Valid Content

In our first code block, we want to ensure the Responded View only pulls valid responses. We’ve set up an “if/do” block where if the value of “ResponseDetails_RT” is greater than or equal to 1, and “response” is not equal to blank – that is, not empty – then our Responded View Repeating Table will automatically insert a row.

This ensures our Responded View only populates rows with valid content.

Second Code Block for Number of Rows

In our second code block, we want to ensure the number of rows doesn’t exceed the number of valid responses. To do this, we create a variable, 'IndexA', that is exactly one row and we use if/do logic to check how many rows to add based on the valid content in 'ResponseDetails_RT'. This ensures our Responded View only produces as many rows as there are responses.

The first part of this block defines our variable – the list IndexA is set to 1 row. Next, the block focuses on those row in “ResponseDetails_RT” where there is content – for each item “i” in the list, where “i” is simply a variable representing valid responses.

The next part of the block contains two if/do logic blocks, where first we check that 'ResponseDetails_RT' has one or more rows (IndexA is less than or equal to 'ResponseDetails_RT'), and then we check that those items are definitely not blank ('i' does not equal " "). Here we set the repeating table functionality.

In the second setup of blocks as per above snapshot, we are checking the length of the repeating table i.e. the number of rows in repeating table. We are setting up a loop by passing an index (i.e. a list) with the variable value 'IndexA' starting from row number '1'. Next, it will check to see if the variable 'IndexA' is less than the length of the repeating table. This means, the index runs based on the number of rows in the repeating table.

'i' is a variable defined for checking the 'response' received within the rows in repeating table. We are setting up a condition where if the response received is not equal to blank, then hide the row. Accordingly, if the response received is equal to blank, then show the row.

On the other view that we need to create for displaying the responses i.e. 'Responded View', we need to show all the responses hence we don't need to setup such condition in that particular view.

In the third setup of blocks, we are hiding the 'Insert' and 'Remove' buttons for the user in the repeating table 'ResponseDetails_RT'. This setup helps avoid users inserting a new row or removing an existing row from the repeating table.

Here are the steps to understand how you can define such a condition:

1. From the left panel, go to first option 'Logic'. It will populate a list of logical blocks. Select the first 'if' block and drag it to the center of the editor.

2. From the block category 'Logic', select the third block which returns true if both inputs are true and drag it to the center adjoining the 'if' block as shown below.

3. From the block category 'Logic', select the second block which returns true if both inputs are equal to each other and drag it to the center adjoining the blank box opposite the 'if' block as shown below.

4. In the block added as per step 3, replace the '=' sign by selecting '≥' (greater than equal to) sign from the dropdown.

5. From the block category 'Lists', select the 4th block which returns the length of a list and drag it to the center adjoining the blank box opposite the 'if' block as shown below.

6. From the block category 'Repeating Table', select the 2nd block to get repeating table value and drag it to the center adjoining the 'length of' block opposite the 'if' block as shown below.

Under the dropdown to get repeating table value, select 'Control Name' as 'ResponseDetails_RT'.

7. From the block category 'Math', select the first block for numeric values and drag it to the center adjoining the blank box opposite 'if' block as shown below.

Edit the number '0' and replace it with '1'.

8. From the block category 'Logic', select the second block which returns true if both inputs are equal to each other and drag it to the center adjoining the blank box opposite the 'if' block as shown below.

In this newly added block, replace the '=' sign by selecting '≠' sign (not equal to) from the dropdown.

9. From the block category 'Custom Functions', select the second block for getting element custom property value, and drag it to the center adjoining the 'and' block as shown below.

Under the 'Control Name' select 'response'.

10. From the block category 'Text', select the first block for text values and drag it to the center adjoining the blank box opposite 'and' block as shown below.

11. From the block category 'Repeating Table', select the third block for setting repeating table functionality as shown below.

Under the 'Functionality' dropdown, select 'Auto Insert Row' and then select 'Control Name' as 'ResponseDetails_RT'.

12. From the block category 'Variables', select the option 'Create Variable' and enter new variable name as 'IndexA' and click 'OK'.

13. From the block category 'Variables', select the second block for setting the selected variable to be equal to the input, and drag it to the center as shown below.

Here,

Here, we need to ensure the variable selection in the dropdown matches the variable 'IndexA' defined as per step 12 above.

14. From the block category 'Math', select the first block for numeric values and drag it to the center adjoining the block for setting variable as shown below.

Edit the number '0' and replace it with '1'.

15. From the block category 'Loops', select the 4th block for setting a variable to each item in the list and then do some statements.

16. From the block category 'Repeating Table', select the 2nd block to get repeating table value and drag it to the center adjoining the 'for each item in list' block as shown below.

Under the dropdown to get repeating table value, select 'Control Name' as 'ResponseDetails_RT'.

17. From the block category 'Logic', select the first 'if' block and drag it to the center of the editor adjoining the 'do' section under 'for each item in list' block as shown below.

18. From the block category 'Logic', select the second block which returns true if both inputs are equal to each other and drag it to the center adjoining the blank box opposite the 'if' block as shown below.

In this newly added block, replace the '=' sign by selecting '≤' (less than equal to) from the dropdown.

19. From the block category 'Variables', select the block which returns the value of 'IndexA' variable (defined as per step 12 above).

20. From the block category 'Lists', select the 4th block which returns the length of a list and drag it to the center adjoining the blank box opposite the 'if' block as shown below.

21. From the block category 'Repeating Table', select the 2nd block to get repeating table value and drag it to the center adjoining the 'length of' block as shown below.

Under the dropdown to get repeating table value, select 'Control Name' as 'ResponseDetails_RT'.

22. From the block category 'Logic', select the first 'if' block and drag it to the center of the editor adjoining the 'do' section under 'if' block as shown below.

23. From the block category 'Logic', select the second block which returns true if both inputs are equal to each other and drag it to the center adjoining the blank box opposite the 'if' block as shown below.

In this newly added block, replace the '=' sign by selecting '≠' (not equal to) from the dropdown.

24. From the block category 'Custom Functions', select the second block for getting element custom property value, and drag it to the center adjoining the 'if' block as shown below.

Under the 'Control Name' select 'response'.

25. From the block category 'Variables', select the block that returns the value of selected variable, and drag it to the center into the 'Get Value' block as shown below.

Here, we need to ensure the variable selection in the dropdown matches the variable selected in the corresponding block 'for each item in list' as per step 15 above.

26. From the block category 'Text', select the first block for text values and drag it to the center adjoining the blank box opposite 'Get Value' block as shown below.

27. From the block category 'Repeating Table', select the third block for setting repeating table functionality as shown below.

Under the 'Functionality' dropdown, select 'Show Row' and then select 'Control Name' as 'ResponseDetails_RT' and uncheck the checkbox for 'Value' if selected.

28. From the block category 'Variables', select the block which returns the value of 'IndexA' variable (defined as per step 12 above), and drag it to the center adjoining the blank box opposite 'Set Repeating Table Functionality' block as shown below. At this stage, you may need to select the '#' value from the dropdown to see the blank box as needed.

29. Select and copy the 'Set Repeating Table Functionality' created as per step 27 and 28, then paste it just below the same block as shown below. Here, you need to select the checkbox for 'Value' (as shown in snapshot).

30. From the block category 'Variables', select the second block for setting the selected variable to be equal to the input, and drag it to the center just below the first 'if' block as shown below.

Here, we need to ensure the variable selection in the dropdown matches the variable 'IndexA' defined as per step 12 above.

31. From the block category 'Math', select the 4th block for returning the sum of two numbers, and drag it to the center adjoining the block for setting the selected variable to be equal to the input as shown below.

32. From the block category 'Variables', select the block which returns the value of 'IndexA' variable (defined as per step 12 above), and drag it to the center opposite the block for setting the selected variable to be equal to the input as shown below.

33. From the block category 'Custom Functions', select the third block 'Setter' for setting element custom property value as shown below.

Under the 'Control Name' dropdown, select 'ResponseDetails_RT' and then select 'Property Name' as 'Show Insert Button' and uncheck the checkbox for 'Value' if selected.

34. From the block category 'Custom Functions', select the third block 'Setter' for setting element custom property value, and drag it to the center just below first 'Setter' block (added as per step 32) as shown below.

Under the 'Control Name' dropdown, select 'ResponseDetails_RT' and then select 'Property Name' as 'Show Remove Button' and uncheck the checkbox for 'Value' if selected.

35. Once done, click 'OK' (at bottom right) to save the changes and exit the code editor, then save / publish the form design as needed. Once the form design is published and executed, the changes will be applicable for the new forms created under the related form type.



Did this answer your question?