- 06 Oct 2021
- 6 Minutes to read
Push Data from a Form to a Data Repeater
- Updated on 06 Oct 2021
- 6 Minutes to read
In Decisions, a Data Repeater displays the data of a Data Structure as a component on a Form. End users may manipulate the data within the Data Repeater as well as transfer data from the Form into the Repeater within the same Form session.
The following example demonstrates how to accomplish this transfer with Data Flows.
Building the Form, Data Repeater, and main Flow
For this example, the Form prompts the user-input for 'tax' and pass that value into a Data Repeater presenting invoice information for different companies. The Repeater then reflects the tax next to the sub-total of each company invoice. An Event Button on the Repeater calculates the total given the sub-total and tax from the Form.
This example uses a Database Structure called 'Invoice' with company, sub-total, tax, and total as data members.
- In a Designer Folder, select the Create Form button from the bottom Action bar. Choose the default template and provide a name for the Form then select CREATE.
- Once the Form Designer opens, search and populate the Form with the following components: a Number Box, a Button, and a Data Repeater.
- Name the Number Box 'Enter Tax' with a Label by submitting with SHIFT+ENTER.
- Select the Data Repeater component to view its Properties tab. Under the Common Properties section, locate the Source box and select CREATE.
- In the Data Repeater Designer, locate the Form Data section of the Properties and designate the Input Type using the appropriate Data Structure.
- In a Designer Folder, select the Create Flow button from the bottom Action bar. Choose the default template and provide a name for the Flow, then select CREATE.
- Search and add the Get All Invoice step and connect it to the Start step. This step acts similarly to the Get All step except it specifies the Invoice Database Structure.
- Add a Show Form step to the Flow and connect the outcome path of the Get All step to it. Pick the Tax Form created earlier so that the corresponding inputs will populate on the Show Form step.
- Select the Show Form step icon to populate the Properties tab. Use the Edit Input Mappings button to map the invoice Results list to Invoice Repeater and the Count of invoices to selected Invoice Repeater Line Number.
Building the Data Flows
Now that the Form containing the Data Repeater is configured to retrieve the invoice results in the main Flow, Data Flows must be configured to pass the Form data to the repeater and calculate the total.
- In the Form Designer, open the Form Properties > Form Rules and select the Add New button under the Data Flows box.
- In the Edit Data Flow window, prioritize the Flow box. Create and name new Data Flow to pass the tax from the main Form into the Data Repeater.
- In the Flow Designer, connect the outcome path of the Start step to the End step.
- Select the Start step to open its Properties, then locate the Flow Input Data section and select the Show Editor button.
- In the Data Definitions window, add a piece of input data called 'Tax' of the data type 'Decimal'.
- Select the End step to open its Properties, then locate the Output section. Choose 'Tax' from the Pick From Current Data box.
- Once the configurations are complete, save and close the Flow.
- Back in the Edit Data Flows window, select the Update Inputs button to view the data from the Flow so that the data from the Flow appears.
- Select the pencil icon next to 'Tax' in the Flow Inputs box. When the window appears, choose Form Component from the Input Type dropdown list then choose Tax from the Form Data Name dropdown list.
- Enable RunOnValueChanged, then select OK.
- Select the pencil icon next to Flow: Tax in the Flow Outputs section. When the window appears, change the name to Form Data.Tax to match the name of the tax component in the Data Repeater.
- Enable the option to refresh all of the components listening to this Data Name so that the tax will be updated when the end-user enters it. Select OK once complete.
- In the Advanced section, select the option to Run at Startup. Once complete, select OK.
- Hover over the Data Repeater Form component and select Edit Source.
- In the Data Repeater Designer, navigate to the Properties > Form Rules. Select the 'Add New' button to create a new Data Flow for the Repeater. This Data Flow will calculate the total.
- Select the Start icon to open its Properties. Select the Show Editor button for Flow Input Data to add SubTotal and Tax of the 'Decimal' data type.
- Select the Multiply step and map the inputs so that value is SubTotal and by Value is Tax. The output result of this will be used to finalize the calculation.
- Select the Add step and map the inputs so that value1 is SubTotal and value2 is Multiply_Output (which is the sub-total multiplied by the tax decimal). The output result of this will be used as the final total, with the tax included.
- Select the End step and use the Show Editor button for Output, then add Total of the 'Decimal' data type. Map the Add_Results output as the input for the Total, which will then pass to the repeater.
- Save and close this Flow once the logic is complete.
- Back in the Edit Data Flows window, select the Update Inputs button so that the data from the Flow will appear in this window to configure.
- Select the pencil icon next to SubTotal in the Flow Inputs box. When the window appears, choose Form Component from the Input Type dropdown list, then choose Form Data.SubTotal from the Form Data Name dropdown list.
- Select the pencil icon next to Tax. When the window appears, choose Form Component from the Input Type dropdown list, then choose Form Data.Tax from the Form Data Name dropdown list.
- Select the pencil icon next to Form Data.Total in the Flow Outputs box. When the window appears, confirm that the Form Data name is Form Data.Total and leave the 'refresh components' box unchecked.
- The last configuration is under the Advanced section. Check the box for the EventButton Click so that the Data Flow will run when the button is selected.
- Save and close both the Data Repeater and main Form.
- Back in the Flow Designer, select the Debug button from the top Action bar.
- Select the option to run a FULL debugger test. When the Form appears, enter a decimal for the tax amount to see that the data moves to the repeater in real-time.
- Select a line item in the repeater and use the Event Button to calculate the total, given the sub-total and tax.
- Take a look at the debugger results to see that the Form was operating via the Data Flows to move the tax and calculate the total, the main Flow does not finish until the OK button is selected.
Below is an attached zip file containing the build used in this example. This file can be downloaded and imported into a Decisions environment using our Import/Export Overview article.