When importing data, a condition on the source form can filter what is being imported. This functionality will require the use of data fields and event attributes on the source form, as well as setting up the desired version of form to form integration (push/pull). When the conditional export field or the condition field is changed, the data field will be set to the value of the conditional export field. It is the value in the data field that will be referenced when importing data via form to form.
Data Field: Data fields are hidden from view, store information, and may be referred to by form functions. They will be created outside of the tabset so that they are always initialized
Content Attribute: This will refer to one of the following attributes based on the desired language. English: content_en-CA, French: content_fr-CA, Spanish: content_es-US.
Condition Element/Field: The condition element is the element that is used to decide whether the data should be imported to the target form or not.
Conditional Export Field: A conditional export field is a field that will have data exported based on the status of the condition field.
Target *: This is a prefix to describe whatever it is that specific functionality is affecting. Some examples include target forms and target drop-downs.
Source*: This is a prefix to describe where specific functionality or data is originating. Some examples include source forms and source drop-downs.
Dynamic Tab(s): Dynamic tabs are tabs that are not initialized on form load. All tabs but the first tab are dynamic tabs.
id: This is a common form attribute. All ids should be unique. When an id is used in the example, an alternative id may be used, however, make sure that when replacing the example’s id with a custom one, the change is consistent throughout.
class: This is a common form attribute. When a class is used in the example, an alternative class may be used, however, make sure that when replacing the example’s class with a custom one, the change is consistent throughout.
When quotation marks are used to describe the value of an attribute, selector, etc. assume the quotes are not part of that value itself. When replacing ids or classes, maintain the quotation structure of the original/provided code.
Form Work – Source Form
There will be a small amount of form work required on both the source and target forms. The source form will require a condition field, a conditional export field, and a data field.
The first step of implementing a conditional data export is to identify or create the condition element. This example will utilize a “status” drop-down as the conditional element.
Give this field a descriptive id. In this example, the id will be “statusField”. If this field is inside of a repeater, give it a class instead.
Conditional Export Field
Once the conditional element is identified or created, the conditional export field must be identified or created. This example will use another dropdown as the conditional export field.
The conditional export field will also need an id. In this example the id is exportField. If this field is inside of a repeater, give it a class instead.
Adding Data Fields
Finally, the data fields must be created in order to store the raw information being imported into the target form. These fields should either be a checkbox or a textbox. A checkbox will store true/false values, or match the values of export checkbox data. A textbox will store any form of text, which can come from elements such as a drop-down, text area, or textbox.
Create a container outside of the tabset.
On this container, add a style of “visibility:hidden;background:aliceBlue;border:1px solid steelBlue;”
Since in this example the import data will be text, a common type “Common: Label | Texbox” will be added into this container as the data field. Give the label element a content attribute with a descriptive value. In this example “Stored Export Data” is used, however, a more tailored value such as “Stored Teacher Name” may be more descriptive.
Give the textbox an id and a description.
Steps 2-4 will need to be repeated for each field being imported into the target form.
Form Work – Target Form
The standard process of setting up form to form should be followed. This means that the fields that are to receive data will require the clevrIntegrationField and clevrIntegrationForm attributes.
This will be the ElementID of the associated data field on the source form.
This will be the FormID of the source form.
Note: These attributes are required on all fields on the target form that are to recieve data through the conditional import.
The source form requires some event attributes in order to properly store the data for conditional import.
Reminder: When quotation marks are used to describe the value of an attribute, selector, etc. assume the quotes are not part of that value itself. When replacing ids or classes, maintain the quotation structure of the original/provided code.
The value for this attribute will be different depending on if the condition field and conditional export field are both within the same repeater. This is so that the conditional export field only checks the value of the conditional field within the same repeater instance, and vice versa. The code will also be different if this field, or the conditional export field is a checkbox.
In this example, the data will be imported to the target form only when the drop-down is set to “Open”. Update this value to that of the desired correct drop-down option.
If this field is a checkbox, replace “$(this).val() === “Open”“ with “$(this).is(“:checked”)”.
If the conditional export field is a checkbox, replace “updateVal” with “updateCheck” and the following “val() with “is(“:checked”)”.
For the checkbox examples, they will export data only if this field is checked. To inverse this use “!$(this).is(“:checked”)” in place of “$(this).val() === “Open”“ instead.
Outside a Repeater:
Inside a Repeater:
Conditional Export Field
When the conditional export field is changed, the value of the condition field will be checked, and if it is the correct value, then the data field will be updated. There will be different code needed if both the conditional export field and the condition field are in a repeater, and for if either of said fields are a checkbox. If this field is a checkbox, then the data field should also be a checkbox.
Again, In this example, that data will be imported only when the drop-down is set to “Open”. Update this value to that of the desired correct drop-down option.
If the condition field is a checkbox, replace “val() === “Open”“ with “is(“:checked”)”.
If this field is a checkbox, replace “updateVal($(this).val())” with “updateCheck($(this).is(“:checked”))”.
For the checkbox examples, they will export data only if the condition field is checked. To inverse this use “!$(“#statusField”).is(“:checked”)” in place of “$(“#statusField”).val() === “Open”“ instead.
Outside a repeater:
Inside a repeater:
This field does not require and event attributes.
The final step when implementing conditional import is to link the source and target forms in the form management module. To do this, go to the form management module for the source form. Next, navigate down to the “Link Form” section and click on “NEW LINK”.
In the resulting popup menu, select the target form from the “Target Form Name” drop-down. Then, if setting up for form to form pull, check the first checkbox. If setting up for form to form push, check both checkboxes. Finally, click SAVE.
If the condition element is outside of a repeater, but the conditional export element is inside of a repeater, then there will be an issue in determining which of the conditional export element instances should be the one to save to the data field. Due to this, it is recommended that if the conditional export element is inside of a repeater, there should be a conditional element also inside of that repeater.
If the conditional element is inside of a repeater, and the conditional export element is not inside of a repeater, there will be an issue in determining which instance of the conditional element to use. If the aim is to check if any of the conditional elements are set to the correct value, then on the conditional export element, on the onchange attribute, in place of “$(“#statusField”).val() === “Open”“ use “$(“#statusField”).oneHasValue(“Open”)”.