Using form data with multiple forms

When using the User service to involve people in processes, you may be required to use more than one form in a process and populate them with the same form data. If all forms use the same layout for the form fields, they can be used interchangeably with the same form data. However, if two form designs use different layouts, form data from one form cannot be automatically merged with the other form. In this case, you need to manipulate the form data so that it properly fills the form.

This Quick Start will be most useful to you if you are already familiar with using forms in processes.

For example, a person fills an order form to purchase parts from a retailer’s online automobile parts catalog and submits the form to initiate the purchase process. The process determines that some of the ordered parts are not in stock and must be ordered from the manufacturer. The process automatically fills a different form to order the parts from the manufacturer and fills this form with data from the customer’s original purchase request.

You can use these strategies to manipulate form data to use it with a different form layout:

  • Make changes to the form data (which is stored in an xfaForm variable) so that the data structure matches that of the form. Use this strategy if the forms use only slightly different field layouts so that adding nodes to the data schema makes them compatible.

  • Copy data items from the form data to an xfaForm variable that uses a data structure that is compatible with the form’s data schema. Use this strategy when the forms use very different field layouts or if you only need to use a subset of the form data.

To implement either strategy, use the Set Value service to manipulate the data stored in form variable .
T o see the form data schemas in XPath Expression Builder, embed the schema in the form.

Prerequisites

To use the same data for two different forms, you need to define two xfaForm variables that hold the form data you are manipulating:

  • One form variable holds the original form data.

  • One form variable holds the form data that is based on the original form data but has been manipulated.

Configuration when forms are similar

If two forms use field layouts that are very similar, you may be able to add nodes to the data from one form so that the data can be successfully merged with the second form. You can use XPath expressions to add nodes to the data model of xfaForm variables.

The following illustration shows the data models of two different xfaForm variables (xfa form1Var and xfa form2Var ) for populating two different forms (Form1 and Form2).

The difference between the two schemas is that the schema for the xfaform2Var variable includes the manufacturerID node below the root node of the form schema. The data in the xfaform1Var variable is made compatible with Form2 by adding a manufacturerID node to its schema.

The following expression adds the manufacturerID node to the data schema of xfaform1Var :

/process_data/xfaform1Var/object/data/xdp/datasets/data/Form1/manufacturerID

This expression is used as the value of the location attribute for a Mapping property of a Set Value service’s execute operation to create the manufacturerID node.

Note: To preserve the original form data, you must copy the data to another variable before you modify the data schema.

Configuration when forms are not similar

You can copy data from the nodes of one xfaForm variable data model to the nodes of another xfaForm variable schema. If two forms use field layouts that are very different, you can copy data items from one form variable to the other form variable so that the data is reused in the second form.

The following illustration shows the data schemas that are required in two different form variables ( firstVar and secondVar ) for populating two different forms (firstform and secondform).

The form called secondform contains fewer fields than firstform so that the data captured using firstform cannot be automatically merged with secondform. However, the data from some firstform fields are appropriate for fields on secondform. You use the Set Value service to copy items of data from the firstVar variable to the secondVar variable.

For example, you would use the Set Value service to set the value of the /process_data/secondVar/object/data/xdp/datasets/data/secondform/item[1]/id node in the secondVar variable to the value of the /process_data/firstVar/object/data/xdp/datasets/data/firstform/item[1]/id node of the firstformVar variable.

Other considerations

The examples in this Quick Start use simple XPath expressions. If required, you can manipulate data with more complex XPath expressions and use XPath functions.

// Ethnio survey code removed