Parent-Child Relationships in Collect Templates

<< Click to Display Table of Contents >>

Navigation:  Collect > Collect Enterprise > Template Designer Page >

Parent-Child Relationships in Collect Templates

Parent-child relationships are created when a subform is created for a form. The form is the parent to the subform, also known as the child form.

 

How is the Parent-Child Relationship Defined?

 

Collect template records, such as a form, are denoted by unique identification numbers known as the #id. A child form contains #parent_#id identification numbers in addition to its own #id.

 

Both the parent form and the child form will each have a unique #id value. To connect the parent form to the child form, the child forms #parent_#id value must match the parent forms #id value. One of the benefits of setting up subforms as a child form to a parent form in the Template Designer is this connection is automatically configured, hence you are able to see the defined child form records under a given parent form in Collect Mobile as seen below:

 

subform_setup_zoom50

 

Note: Parent forms do not have a #parent_#id field to populate.

 

The parent-child relationship defined between a form and its subform spans across many steps in the EQuIS Collect workflow, as outlined in the sections below.

 

Parent-Child Relationships in Pre-population

 

To pre-populate a child form record, the parent record needs to be pre-populated first, otherwise the child form record is orphaned in Collect Mobile. To do so, pre-populate the parent record and use a value from the report table that is unique for each record being pre-populated to populate the #id field value. For example, a sample record is to be pre-populated, the sampleid is a unique value appropriate for populating the #id value.

 

Once the parents form #id value is configured, in the pre-population of the child form, set the #parent_#id to the same value as the parent form’s #id value.

 

Note: The unique value chosen to pre-populate the parent form’s #id value should be present in both report tables used to pre-populate the child and parent form.

 

Parent-Child Relationships in the Formula Builder

 

The #id and the #parent_#id fields discussed in this article are available for selection in the Formula Builder under Section Fields:

 

Formula_Builder-id_parent_id_fields

 

Populating a Child Form Field with a Value From the Parent Form

 

To populate a child form field with a value from a field in the parent form, add the following prefix to the field name of the field in the parent form, #parent_[ParentFieldName]

 

Example:

 

Template Setup:
 

Parent Form: FieldA

oChild Form: FieldB

 

Scenario: You want the value of FieldA from the parent form to populate FieldB in the child form by default.

 

Solution: You can call upon FieldA to populate FieldB's Default attribute using the following field:

 

[#parent_FieldA]

 

Parent-Child Relationships in the FormFilter Attribute or FILTER Function

 

Filtering out child records that belong to a given parent record can be useful when creating a set of data records for a formula especially in the FormFilter attribute for fields such as the Table Form or Form Lookup fields using the FILTER function.

 

Scenario A: To filter all associated child form records of a parent form, while in the parent form records, use the following formula in the condition parameter of the FILTER function:

 

EQ([#id],[ChildFormName.#parent_#id])

 

Where ChildFormName is the name of the child form.

 

Example:

 

FILTER(EQ([#id],[ChildFormName.#parent_#id],[ChildFormName.Field])

 

Scenario B: To filter all the child form records belonging to the same parent form, while in the child form, use the following formula in the condition parameter of the FILTER function:

 

EQ([#parent_#id],[ChildFormName.#parent_#id])

 

Where ChildFormName is the name of the child form.

 

Example:

 

FILTER(EQ([#parent_#id],[ChildFormName.#parent_#id]),[ChildFormName.Field])