- 20 May 2022
- 6 Minutes to read
- Print
- DarkLight
Mixed Type Repeater
- Updated on 20 May 2022
- 6 Minutes to read
- Print
- DarkLight
Overview
The Mixed Type Repeater control allows a Decisions Form to dynamically display which type of repeater to display based on a user's input. Users can also display different custom data types or primitive data types. A common use case for the Mixed Type repeater is for creating dynamic surveys. When creating a survey, users can use the mixed type repeater to populate different types of survey questions like a radio button list, true or false question, or multiple-choice question.
Example
In this example, a Form will give the user the ability to create a custom dropdown list repeater with a label or a text data repeater with a label. Both repeaters will have the ability to be instantiated by the click of a button. There is also an add to list event that will be is used to add elements to the drop-down lists.
An example lab project about creating a mixed type data repeater is available to follow alongside this article. An example lab offers the reader a downloadable Decisions file available for importing into the reader's own Decisions instance alongside a thorough an explanation of its configuration. After importing the file, the reader may examine the functional project at their own pace from within the platform.
Please refer to our Creating a Mixed Type Data Repeater Example Lab to review, download, and import the project.
- In the Designer Project, click CREATE DATAYPES/INTEGRATION on the Global Action Bar and select Defined Data Structure.
- Enter "Text_Element" in the Structure Type Name field. Configure the Structure to have two String data members (Data, Name) and click SAVE.
- Create a second Defined Data Structure with the Structure Type Name as "Dropdown_Element" and three String data members (List, Data, Name). Click the Is List checkbox next to the List data member. Then, click SAVE.
- Create a third and final Defined Data Structure, type "Element" in the Structure Type Name field. Configure the Structure to have two String data members (Data, Name) and click SAVE.
- Click CREATE FLOW from the Global Action Bar and select Flow. Name the Flow (Main Flow) and select CREATE.
- Click the Done path on the Start step. Select the Show Form step and click ADD.
- With the Form step selected, click PICK OR CREATE FORM and select CREATE.
- On the Create New dialog window, select Form and name the Form. Then, select CREATE.
- Configure the Form to have the following controls and Data Names:
Form Control Location in Toolbox Data Name Button Actions Button Text Box Data Name Event Button Actions > Events EventButton_Text Event Button Actions > Events EventButton_Dropdown Text Box Data AddToList Event Button Actions > Events EventButton_Add_List List Box Data List Mixed Type Repeater User Controls Elements - Select the Mixed Type Repeater Control. In the Data Name text box under COMMON PROPERTIES, type "Elements".
- Click ADD NEW under Sources and select PICK SOURCE. On the dialog window, select CREATE and click User Defined Control. Enter a name (Dropdown User Control List) and click CREATE.
- When the Form Designer opens, select SETUP INPUT DATA.
- In the Name field enter "Dropdown_Element". Click the Type field dropdown list and navigate to User Defined Types > Defined Data Structures and select Dropdown_Element.
- Click Save and then close the window.
- On the Data panel, expand DROPDOWN_ELEMENT. Click and drag the Name field to the Form and select Label Of Data Value on the pop-up menu. Then, press Enter to save control.
- In the Toolbox panel, drag and drop a Drop Down List control to the Form under the Label.
- Under the INPUT DATA category on the Properties panel, click the Type dropdown list and select String [Text]. Expand the List Input Source dropdown and select DataName.
- Under List Items DataName field click PICK FROM DATA. Expand Dropdown_Element and select List. Then, click PICK.
- Save and close Form Designer. Then, select OK on the Add Sources dialog window.
- Back in the Form Designer, select the Mixed Type Repeater Control again.
- Click ADD NEW under Sources and select PICK SOURCE. On the dialog window, select CREATE and click User Defined Control. Enter a name (Text User Control List) and click CREATE.
- When the Form Designer opens, select SETUP INPUT DATA.
- In the Name field enter "Element". Click the Type field dropdown list and navigate to User Defined Types > Defined Data Structures and select Element.
- Click Save and then close the window.
- On the Data panel, expand ELEMENT. Click and drag the Name field to the Form and select Label Of Data Value on the pop-up menu. Then, press Enter to save control.
- In the Toolbox panel, drag and drop a Text Box control to the Form under the Label.
- Under the COMMON PROPERTIES category on the Properties panel, under Data Name, select PICK FROM DATA. Expand Element and select Data. Then, click PICK.
- Click Save and close Form Designer. Then, click OK on the Add Sources dialog window.
- Select SETUP INPUT DATA on the Form, add Elements (Object-List), Name (String), List (String-List), Item (String).
Drop Down Active Form Flow
- Click the workspace around the Form. In the Properties panel, scroll down to the FORM RULES > Active Form Flows, select ADD NEW.
- Name the Flow "Add Drop Down Element" and Select EDIT RULE FLOW.
- On the outcome path of the Start step, add a Create Data step.
- In the properties of the Create Data step navigate to DATA > Data to Create, select Show Editor.
- Name this DropdownItem with the data type Dropdown_Element.
- On the Create Data step Inputs, choose Build Data as the mapping type.
- For List, select Form Input Data > List. For Name, select Form Input Data > Name.
- On the outcome path of the Create Data step, add a Set Control Value step.
- In the Set Control Value step Properties, navigate to Inputs, select Form Data > User Control List Container for the Form Control.
- Under Elements, select Join Arrays as the mapping type.
- For Item 0 select Form Input Data > Elements, for Item 1 select Build Array as the mapping type, then for Item 0 choose DropdownItem.
- Save and close the Flow. Back in the Edit Active Form Flows dialog, under ADVANCED > Triggers, choose EventButton_Dropdown: Click.
- Select OK to save.
Text Element Active Form Flow
- Click the workspace around the Form. In the Properties panel, scroll down to the FORM RULES > Active Form Flows, select ADD NEW.
- Name the Flow "Add Text Element" and Select EDIT RULE FLOW 1.
- On the outcome path of the Start step, add a Create Data step.
- In the properties of the Create Data step navigate to DATA > Data to Create, select Show Editor.
- Name this TextElement with the data type Text_Element.
- On the Create Data step Inputs, choose Build Data as the mapping type.
- For Name, select Form Input Data > Name.
- On the outcome path of the Create Data step, add a Set Control Value step.
- In the Set Control Value step Properties, navigate to Inputs, select Form Data > User Control List Container for the Form Control.
- Under Elements, select Join Arrays as the mapping type.
- For Item 0 select Form Input Data > Elements, for Item 1 select Build Array as the mapping type, then for Item 0 choose TextElement.
- Save and close the Flow. Back in the Edit Active Form Flows dialog, under ADVANCED > Triggers, choose EventButton_Text: Click.
- Select OK to save.
Add to List Active Form Flow
- Click the workspace around the Form. In the Properties panel, scroll down to the FORM RULES > Active Form Flows, select ADD NEW.
- Name the Flow "Add to List" and Select EDIT RULE FLOW 2.
- On the outcome path of the Start step, add an Add Item to List step.
- In the properties of the Add Item to List step, navigate to Inputs, under New Item choose Select From Flow as the mapping type and select Form Data > Add to List Text Box > Value.
- For Original List select Form Input Data >List from the Select from Flow option
- Under Outputs, change the value of New List to Form Input Data > List
- On the outcome path of the Add Item to List step, add a Set Control Value step.
- In the Set Control Value step Properties, navigate to Inputs, select Form Data > Simple List for the Form Control.
- Under Item Source, select Form Input Data > List.
- Save and close the Flow. Back in the Edit Active Form Flows dialog, under ADVANCED > Triggers, choose EventButton_Text: Click.
- Select OK to save.
Debug
- Back in the Main Flow connect the Show Form step to the End step.
- Select Debug and verify that the Flow works properly.