The Dispatch API allows you to send a form Dispatch with pre-populated answers for the user. This extension to the API enables you to replace resources used in the original form with different ones in the Dispatch.

If you had an Attached File question in your form that was a schematic diagram to help the user complete the form, for example, you could set that schematic to one for the location where the dispatched form is being worked on:

JSON

{
  "form_namespace" : "http://www.devicemagic.com/xforms/...",
  "payload" : {
    "site_address" : "12 34th st..."
  },
  "resource_replacements": [
    {
      "question" : "section_1/schematic_1",
      "old_resource": "609cc82f-0e...",
      "new_resource": "14740f11-d1..."
    }
  ]
}

XML

<oneshot xmlns="http://www.w3.org/2002/xforms" xmlns:dm="http://mobileforms.devicemagic.com/xforms">
  <dm:form_namespace>http://www.devicemagic.com/xforms/...</dm:form_namespace>
  <site_address>12 34th st...</site_address>
  <dm:resource_replacement>
    <dm:question>section_1/schematic_1</dm:question>
    <dm:old_resource>609cc82f-0e...</dm:old_resource>
    <dm:new_resource>14740f11-d1...</dm:new_resource>
  </dm:resource_replacement>
</oneshot>

When the resource being used is tabular data, you'll need to replace the identifiers for the resource, as well as the tables and columns being used, e.g. for select options, lookups, data binding, or select filtering expressions:

JSON

{
  "form_namespace" : "http://www.devicemagic.com/xforms/...",
  "resource_replacements": [
    {
      "question" : "*",
      "old_resource": "609cc82f-0e...",
      "new_resource": "14740f11-d1...",
      "table_replacements": {
        "80a40c5f-7e...": "58b683e5-ec...",
        "5eccb830-86...": "e61776a6-e1..."
      },
      "column_replacements": {
        "471ab683-4d...": "d0531cf5-de...",
        "0464c245-9c...": "df7ede4c-9e..."
      }
    }
  ]
}

XML

<oneshot xmlns="http://www.w3.org/2002/xforms" xmlns:dm="http://mobileforms.devicemagic.com/xforms">
  <dm:form_namespace>http://www.devicemagic.com/xforms/...</dm:form_namespace>
  <dm:resource_replacement>
    <dm:question>*</dm:question>
    <dm:old_resource>609cc82f-0e...</dm:old_resource>
    <dm:new_resource>14740f11-d1...</dm:new_resource>
    <dm:table_replacement>
      <dm:old_table>80a40c5f-7e...</dm:old_table>
      <dm:new_table>58b683e5-ec...</dm:new_table>
    </dm:table_replacement>
    <dm:table_replacement>
      <dm:old_table>5eccb830-86...</dm:old_table>
      <dm:new_table>e61776a6-e1...</dm:new_table>
    </dm:table_replacement>
    <dm:column_replacement>
      <dm:old_column>471ab683-4d...</dm:old_column>
      <dm:new_column>d0531cf5-de...</dm:new_column>
    </dm:column_replacement>
    <dm:column_replacement>
      <dm:old_column>0464c245-9c...</dm:old_column>
      <dm:new_column>df7ede4c-9e...</dm:new_column>
    </dm:column_replacement>
  </dm:resource_replacement>
</oneshot>

If you only want to replace the resource for a particular question, provide the question path in the resource replacement. Using * or leaving out the question will replace all occurrences of the resource in the form. Multiple resources can be replaced as part of the Dispatch payload.

If you have any questions or comments feel free to send us a message at support@devicemagic.com.

Did this answer your question?