By calling the
loadRecord you can load a respondent record that completed another survey and then examine the data.
<exec> rec = loadRecord("my/other/survey", "source", "12345") if not rec: # No data for source = 12345 found else: p.something = rec.q4.r3.val </exec>
1: Loading a Respondent Record
To load a respondent record, simply call
loadRecord with the survey path, the extra variable name and the value to search for. The survey you are loading data from must have
indexed="source" set: this survey attribute saves the position of each record for each source value. This attribute can be safely added to an existing survey though updating the index for the first time can take a while.
The survey you are loading data from must have its variable defined in the
extraVariables attribute. Sample source variables do not work with indexed.
You can use
loadRecord in virtual questions as well. Remember each time you call
loadRecord, you are doing a considerable amount of work. Thus, if you plan to use data from the same respondent multiple times, you should use
<exec when="virtual"> to load it once for a respondent, then use it in multiple virtuals:
<exec when="virtual"> rec = loadRecord("other/survey", "source", "12345") </exec> <radio …> <virtual> if rec: vq1.r1.val = rec.q4.r3.val </virtual>
2: Limitations and Additional Considerations
The following limitations apply when using
- Only data from real (non-virtual questions) can be retrieved
- Data like
uuid, markers and extra variables cannot currently be retrieved
- Data is read-only
- Once you call
loadRecord, use the data immediately in the same
<exec>block. Do not save the record object or anything but values (i.e retrieved with
- Retrieving the record data must load the survey and the record into memory. If your survey is really large, that may cause a respondent timeout error. As a rule of thumb, if after you modify your
survey.xmland reload a page it takes more than 10 seconds for the page to come up, your survey is too large to be a
- Only extra variables can appear in the indexed attribute. If you want to allow access to any other field, you must save it in an
extraVariable(use the new
setExtra()function to do so easily).
- You cannot load data from your own survey
loadRecordreturns a boolean
falsevalue if it does not find any matching data (i.e. you can assign it to a value, and then check “if not record” to see if you didn’t find anything).
- Avoid using
loadRecordon a survey with partials /
autoRecover="1". If there are multiple records for that same ID, you may get the partial one.
Requires Decipher Cloud
loadRecord in Secure Surveys
loadRecord function can also be used in a secure (
selfserve) survey; however, the survey having its data loaded must have an
acl.txt file containing the path of the loading survey in it. An
acl.txt file should be a flat form file of the survey path(s) that can access the current survey directory for reading, and the format of each path should be
If you would like to grant broader access to the survey, the following wildcards can be used:
selfserve/XYZ/*: will grant access to all client surveys
selfserve/*: will grant access to all surveys in the
*: will grant access to all created surveys
temp-XXX survey uses the name of its parent survey to determine access.