Dynamic Data Attachments

Last updated: 5 Aug 2021

This support article illustrates how data from one project can be linked dynamically and referenced by other projects. It also aims to demonstrate some practical examples that this feature supports.

Dynamically linking projects allows for the same powerful capabilities as the pulldata() function but without the need to maintain a separate CSV file since the data stored in a linked project acts as the data source. Users can continue collecting data in the parent project and simultaneously use that data in other linked child projects, therefore enable creation and management of longitudinal survey projects (longitudinal data is collected through a series of repeated observations of the same subjects over a short or long period). Users can also dynamically link a child project with a shared parent project.

Users can retrieve any (non-media) responses (text, integer, decimal, select_one, select_multiple, etc.) in a linked child project (Round 2 in this example) that has already been collected and stored in the parent project (Round 1 in this example).

Users can also perform various calculations on linked data in the child project, such as counting (count()) responses and computing the sum (sum()), maximum (max()), or minimum (min()) value of a particular variable.

Dynamically linking projects in XLSForm

Dynamically linking projects requires a parent project and at least one child project. The parent project requires no additional modification from a normal XLSForm; however, the child project involves adding an xml-external question type. All subsequent references to the parent project occur in the calculation column using the node path.

Users could design their parent project as shown in the image below:

Round 1

In the same way, users could design their child project as shown in the image below:

Round 2

Note: The name used for the xml-external question type in the child project is crucial for linking with the parent project. In the above example, it was named “survey”, but it can be any name consisting of Latin characters and numbers.

Understanding the syntax used in the calculation column of the child project

XLSForm Syntax

Description

count(instance('survey')/root/data[P_Enumerator])

Return the total count of P_Enumerator in the parent project.

count(instance('survey')/root/data[P_Enumerator = current()/../C_Enumerator])

Return the total count of where C_Enumerator in the child project is equal to P_Enumerator in the parent project.

instance('survey')/root/data[P_Demographic/P_SN = current()/../C_SN]/P_Demographic/P_Name

Return P_Name (P_Demographic group) from the parent project where C_SN in the child project is equal to P_SN in the parent project.

instance('survey')/root/data[P_Demographic/P_SN = current()/../C_SN]/P_Demographic/P_Age

Return P_Age (P_Demographic group) from the parent project where C_SN in the child project is equal to P_SN in the parent project.

instance('survey')/root/data[P_Demographic/P_SN = current()/../C_SN]/P_Demographic/P_Sex

Return P_Sex (P_Demographic group) from the parent project where C_SN in the child project is equal to P_SN in the parent project.

instance('survey')/root/data[P_Demographic/P_SN = current()/../C_SN]/P_Demographic/P_Family

Return P_Family (P_Demographic group) from the parent project where C_SN in the child project is equal to P_SN in the parent project.

sum(instance('survey')/root/data/P_Demographic/P_Family)

Return the sum of P_Family (P_Demographic group) from the parent project.

max(instance('survey')/root/data/P_Demographic/P_Family)

Return the maximum value entered in P_Family (P_Demographic group) from the parent project.

min(instance('survey')/root/data/P_Demographic/P_Family)

Return the minimum value entered in P_Family (P_Demographic group) from the parent project.

instance('survey')/root/data[P_Demographic/P_SN = current()/../C_SN]/P_Demographic/P_Language

Return P_Language (P_Demographic group) from the parent project where C_SN in the child project is equal to P_SN in the parent project.

instance('survey')/root/data[P_Demographic/P_SN = current()/../C_SN]/P_Demographic/P_Location

Return P_Location (P_Demographic group) from the parent project where C_SN in the child project is equal to P_SN in the parent project.

Setting up for dynamic linking

Users can link projects dynamically in two scenarios:

  1. The same user owns both the parent project and child project, and

  2. Different users own each of the projects and the parent project is shared

1. Both projects owned by the same user

Follow the steps below to dynamically link projects:

Step 1: Upload and deploy the parent project.

Step 2: Enable data sharing with child projects by toggling the Data Sharing switch in the parent project’s SETTINGS>Connect Projects section (disabled by default), and click ACKNOWLEDGE AND CONTINUE in the confirmation modal. Users can then restrict specific variables to share with child projects or share all variables from the table by toggling the Select specific questions switch.

Step 3: Upload and deploy the child project.

Step 4: In the child project’s SETTINGS>Connect Projects, click the Select a different project to import data from dropdown menu and select a parent project to link. Rename the linked parent project to the same xml-external question name defined in the XLSForm (“survey” in this example) and click IMPORT. You can then select specific variables from the parent project to share with the child project.

The child project now has access to data from the parent project. In this example, data from the Round 1 Survey is linked to the Round 2 Survey.

2. Projects owned by different users

Assume a scenario where userA has a parent project shared with userB. userB can create a child project and link it dynamically with that project. For example:

Step 1: userA should follow Step 1 and Step 2 of Both Projects Owned by Same User to upload, deploy and configure the parent project.

Step 2: userA should then share the parent project with userB and grant the minimum permissions of: View form and View submissions. userB can now dynamically link their child project to the parent project of userA.

Step 3: userB should now upload, deploy and configure their child project as outlined in Step 3 and Step 4 of Both Projects Owned by Same User.

Collecting and managing data with dynamic linking

Users can collect data for dynamically linked projects on both the Collect Android app and Enketo web form.

Please note the following when collecting data:

  • At least one submission must be present in the parent project for the child project to function as expected.

  • There is a five-minute delay syncing the parent project’s updated data with the child project.

  • Frequently download the child project in Collect or Enketo (when in offline mode) to ensure the data is in sync with the parent project*

*One can configure the Collect Android app, with an internet connection, to update the parent project’s data automatically in General Settings>Form management>Blank form update mode>Previously downloaded forms only or Exactly match server. Note that enabling this setting could drain your device’s battery faster than usual.

In this example, some “dummy” entries have been made in the parent project.

Data

With some dummy entries in the parent project, the child project can now see that data during data collection. In this example child project (Round 2 Survey), only the two fields of Enumerators name and Identification Number are entered manually while the rest is linked automatically with the parent project.

Enketo web form