Form Submission Formats: Standard vs. Labels as Node Names
About
The XML input format can be selected for programmatic-type documents -- XML and JSON. There are two different XML structures available; the difference lies in the naming of nodes containing question/answer information. "Labels as Node Names" may be more suitable if less generic node names are needed.
The full Standard XML structure is listed below, with differences between this format and the "Labels as Node Names" format noted afterwards.
Standard XML Data Format
General Structure
The dataRecord root element has a number of child elements. For the sake of simplicity, this article will group all children of dataRecord into two groups: form-level information (sibling elements that contain general information about the data record), and "pages" (an element with children organizing page and answer data).
dataRecord
The dataRecord node is the root element.
Attributes:
- identifier (used in referenceNumber)
- version (v2)
- zone (device time zone)
<dataRecord xmlns="https:/..." xmlns:xsi="http:/..." xsi:schemaLocation="https://..." identifier="18489010" version="v2" zone="America/Toronto"> ... </dataRecord>
Form Information
About
- These nodes are: children of "dataRecord"
- Siblings to "pages"
- Elements do not repeat
Reference Number
The data record reference number. Formatted as "Date Submitted-datarecord identifier" (see above).
<referenceNumber> 20140613-1813302612 </referenceNumber>
State
The data record state. Options: Complete | Dispatched | Declined
<state> Dispatched </state>
Submit Date
There are three to four elements containing information on when the data record was submitted.
- deviceSubmitDate: Date/time submitted in device time zone.
- shiftedDeviceSubmitDate: deviceSubmitDate translated to server timezone (EST).
- serverReceiveDate: Date/time the TrueContext server received the data record.
- dispatchDate: Included if state (see above) = dispatched. Date/time the data record was dispatched from the TrueContext server.
<deviceSubmitDate> <time>2014-06-13T13:28:05-04:00</time> <zone>America/Toronto</zone> </deviceSubmitDate> <shiftedDeviceSubmitDate>2014-06-13T13:28:05-04:00</shiftedDeviceSubmitDate> <serverReceiveDate>2014-06-13T13:28:07-04:00</serverReceiveDate> <dispatchDate>2014-06-11T13:28:07-04:00</dispatchDate>
Form
Contains information abut the form/form version the data record was submitted against.
- Attributes: "identifier"
- Elements:
- versionIdentifier: The identifier for the version of the form the data record was submitted against.
- name: The name of the form the data record was submitted against.
- version: The version number of the form.
- formSpaceidentifier: The identifier of the FormSpace FormSpaces are where forms are stored and organized in the TrueContext Web Portal. A TrueContext Team may have multiple FormSpaces, depending on their needs. Admins can set FormSpace permissions to control which users have access to the forms in that FormSpace. the form is in.
- formSpacename: The name of the FormSpace the form is in.
<form identifier="141413001"> <versionIdentifier>152110416</versionIdentifier> <name>Demo Questions</name> <version>20</version> <formSpaceIdentifier>191162042</formSpaceIdentifier> <formSpaceName>1- Demo FormSpace</formSpaceName> </form>
User
Contains information on the user who was logged into the device that submitted the data record (the data record submitter).
- Attributes: "identifier"
- Elements:
- username: TrueContext username
- displayName: First Name, Last Name (username)
<user identifier="13548142"> <username>johndoe@abc.com</username> <displayName>John Doe (johndoe@abc.com)</displayName> </user>
Dispatcher
This element is included when the data record state = dispatched. It contains information on the TrueContext user who dispatched the form.
- Attributes: "identifier"
- Elements:
- username: TrueContext username
- displayName: First Name, Last Name (username)
<dispatcher identifier="13548142"> <username>johndoe@abc.com</username> <displayName>John Doe (johndoe@abc.com)</displayName> </dispatcher>
GeoStamp
This element is included when the form the data record is submitted against is configured with a form-level geostamp.
- Elements:
- success: Tells if a geostamp was successfully acquired (Options: true | false)
- captureTimestamp
- provided: Date/Time geolocation was acquired in device time zone
- time
- zone
- shifted: Date/Time geolocation was acquired, translated to server time zone
- provided: Date/Time geolocation was acquired in device time zone
- source: what tool/service on the device was used to acquire the location (Options: GPS | Network)
- coordinates
- latitude
- longitude
- altitude
- address
<geoStamp> <success>true</success> <captureTimestamp> <provided> <time>2014-06-13T13:27:56-04:00</time> <zone>America/Toronto</zone> </provided> <shifted>2014-06-13T13:27:56-04:00</shifted> </captureTimestamp> <source>GPS</source> <coordinates> <latitude>45.348002905586</latitude> <longitude>-75.9196980421965</longitude> <altitude>91.3237</altitude> </coordinates> <address>523 Legget Drive, Ottawa, ON, CA</address> </geoStamp>
Pages and Answers
The "pages" element appears after all the data record-level information elements and is a sibling to them. Values are contained within answers; answers are contained within pages. The structure is as follows.
- pages
- page: Occurs min. once, repeat per page (Attributes: "name").
- answers: No repeats per "page."
- answer: Repeat per form question (Attributes: "label" (no duplicates allowed in form), "dataType" (see next section))
- values: No repeats per "answer."
- value: The answered value. Can repeat in the case of multi-select questions (Attributes: sometimes has "identifier" (attachment data types)).
<pages> <page name="Page 1"> <answers> <answer label="New Question 1" dataType="FreeText"> <question>New Question</question> <values> <value>Testing</value> </values> </answer> <answer label="New Question 2" dataType="FreeText"> <question>New Question</question> <values> <value>Testing Again</value> </values> </answer> </answers> </page> </pages>
Standard XML Format vs. Labels as Node Names Format
The Standard XML Format is listed above.
The "Labels as Node Names" XML format differs only in the Pages/Answers section of the data record (the "Form Information" section is identical). In "Labels as Node Names" format the node containing each question and the corresponding value is named with the question label. As question labels are unique in a form, each "answer" node will be uniquely named. Each "answer" node still has a label, as well. Question labels are assigned in the form builder.
<pages>
<page name="Page 1">
<answers>
<CompanyName label="Company Name" dataType="FreeText">
<question>Company Name</question>
<values>
<value>1</value>
</values>
</CompanyName>
<Address label="Address" dataType="FreeText">
<question>Street Address</question>
<values>
<value>123 Avenue Street</value>
</values>
</Address>
</answers>
</page>
</pages>