1. Home
  2. XLSForm Authoring
  3. How to: Link a dataset as a media file to another form

How to: Link a dataset as a media file to another form

To link another dataset to a form in your Ona account, navigate to the form’s Settings page, then select Form Media Files.

Click on Select dataset to link to get a list of the forms and filtered datasets that you can link to your form.

This opens the Link a dataset window where you can select the project in which the dataset is located, then the name of the dataset to be linked. In the File name field, fill in the name you wish to call the linked dataset.

Click on Link Dataset to save the changes. Your linked dataset will appear on the page.

Now that the dataset is linked to your form, you can pull data from the linked dataset into your form using the pulldata function under the calculation column.

The file name of the linked dataset entered above will be the file name referenced in the pulldata() function (i.e., locations).

The field name from which data is being pulled from the linked dataset (i.e., the data value from the region column in the linked dataset) should be referenced in the pulldata() function exactly as it appears in the linked dataset.

You can then reference this value in notes (as in the example above), constraints, relevant fields, etc., just as you would reference any other field.

Pulling data from a group

To pull data from a group, define both the group name and field name of the column in the linked dataset where the data will be pulled from in the pulldata() function. Make sure to use the Period(.) as the separator between the group and field names as shown in the example below;

Below is a brief description of the parameters in the function pulldata(‘locations’, ‘section1.county’, ‘secction1.id’, ${id})

  • locations is the file name of the linked dataset.
  • section1.county is the column in the linked dataset where the data will be pulled from. section1 is the group name, and county is a field name defined under the group.
  • section1.id is the key field to lookup with section1 being the group name and id a field name defined under that group.
  • id is the link to the row in the lookup field, which is defined in the XLSForm that’s pulling data from the linked dataset.

Pulling data from a repeat group

To pull data from a repeat group, define both the repeat group name and field name of the column in the linked dataset from which data will be pulled in the pulldata() function. You will need to define all the iterations in the repeat group in order for all the data within the repeat group to be pulled. In the pulldata() function, use underscores as the separator between the repeat group name and iterations, and the period (.) as the separator between the repeat groups and field names as shown in the example below.

The parameters in the pulldata() function are explained in details below,

pulldata(‘child4’, ‘chrepeat_1_.chname’, ‘hh_id’, ${hh_id})

  • child4is the filename of the linked dataset.
  • chrepeat_1_.chnameis the column in the linked dataset where data will be pulled from. chrepeat is the repeat group name,_1_ is the first iteration in the repeat group and chname is the field name defined under the repeat group.
  • hh_id is the key field to lookup, which is defined before the repeat group. This has to be defined in the linked dataset and the current form.

Note:
The linked dataset is a live dataset that can change after a user initially downloads the form that it is linked to. If the linked dataset changes (i.e., data is added, edited, or deleted), the form it is linked to has to be downloaded again in ODK Collect for the user to be able to have the latest updates to the linked dataset. Before downloading the form again, make sure you submit all pending form submissions in ODK Collect.

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support