AEM 6.4 has reached the end of extended support and this documentation is no longer updated. For further details, see our technical support periods. Find the supported versions here.
Your customers are often required to submit multiple forms to apply for a service or benefit. It involves finding all relevant forms; and filling, submitting, and tracking them separately. Also, they are required to fill in common details multiple times across forms. The entire process becomes cumbersome and error-prone if it involves large number of forms. The forms set feature of AEM Forms can help simplify the user experience in such scenarios.
A form set is a collection of HTML5 forms grouped together and presented as a single set of forms to end users. When end users start filling a form set, they are seamlessly transitioned from one form to another. At the end, they can submit all forms in just one click.
AEM Forms provides form authors an intuitive user interface to create, configure, and manage form sets. As an author, you can order forms in a particular sequence you want end users to follow. Also, you can apply conditions or eligibility expressions on individual forms to control their visibility based on user inputs. For example, you can configure the spouse details form to appear only when the marital status specifies as Married.
In addition, you can configure common fields in different forms to share common data bindings. With proper data bindings in place, end users are required to fill common information only once that gets auto-filled in subsequent forms.
Form sets are also supported in AEM Forms app, allowing your field workforce to take a form set offline, visit customers, input data, and synchronize later with the AEM Forms server to submit forms data to business processes.
You can associate several XDPs or Form Templates, created using Designer, into a form set. Form sets can then be used selectively render the XDPs based on values entered by the users in initial forms and their profiles.
Use AEM Forms user interface to manage all your forms, form sets, and related assets.
To create a form set, do the following:
Select Forms > Forms and Documents.
Select Create > Form Set.
In the Add Properties page, add the following details and click Next.
The Select Form(s) screen displays the available XDP forms or XDP files. Search and select the forms to include in the form set and then click Add To Form set. If necessary, search again for forms to add. After adding all forms to the form set, click Next.
Ensure that the field names in XDP forms do not contain the dot character. Otherwise, any scripts trying to resolve the fields, which have dot characters, are unable to resolve them.
In the Configure Form(s) page, you can do the following:
fs.valueOf(<Form Identifier>, <fieldSom expression>) > <value>
For example, if you have two forms in the form set: business expense and travel expense, you can add a JavaScript snippet in the Eligibility Expression field for both of these forms to check user input for type of expense in a form. If the user chooses Business Expense, the Business Expense form is rendered to the end user. Or if the user chooses travel expense a different form is rendered to the end user. For more information, see Eligibility Expression.
Additionally, the Author may also choose to remove a form from the form set using the Delete icon present at the right corner of each row or add another set of forms using the ‘+’ icon in the toolbar. This ‘+’ icon directs the user back to the previous step in the wizard, that was used to ‘Select Form(s)’. The existing selections are maintained and any additional selection made must be added to the form set using the Add To form Set icon on that page.
All the forms that are used in form set are managed by AEM Forms user interface.
Once a form set is created, you can perform following actions on that form set:
To edit a form set, do the following:
Select Forms > Forms and Documents.
Locate the form set you want to edit. Hover over it and select Edit ( ).
In the Configure Form(s) page, you can edit the following:
You can also click the relevant Delete icon to delete the form from the form Set.
Once you have created a form set using AEM Forms Management user interface, you can use the form set in a Start Point or Assign Task activity using Workbench.
When designing a process, under the Presentation & Data section of Assign Task/Start Point, select use a CRX asset. CRX Asset browser appears.
Select form set to filter the form set in AEM repository (CRX).
Selects a form set and click OK.
Eligibility expressions in a form set are used to define and dynamically control forms that are displayed to a user. For example, to display a particular form only if the user belongs to a particular age group. Specify and edit an eligibility expression using forms manager.
An eligibility expression can be any valid JavaScript statement that returns a Boolean value. The last statement in the JavaScript code snippet is treated as a Boolean value that determines the eligibility of the form based on the processing in the rest (previous lines) of the JavaScript code snippet. If the value of the expression is true, the form is eligible to be displayed to the user. Such forms are known as eligible forms.
Eligibility expression for the first form in form set is not executed. The first form is always displayed regardless of its eligibility expression.
In addition to the standard JavaScript functions, form set also exposes the fs.valueOf API that provides access to the value of a field of a form in a form set. Use this API to access the value of a form field in a form set. The API syntax is fs.valueOf (formUid, fieldSOM), where:
Both formUid and fieldSOM parameters must be string literal.
Valid usage of the API:
fs.valueOf("form1", "xfa.form.form1.subform1.field1")
Invalid usage of the API:
var formUid = "form1";
var fieldSOM = “xfa.form.form1.subform1.field1"; fs.valueOf(formUid, fieldSOM);
Form set is a collection of multiple HTML5 forms that have common or different schemas. Form set supports prepopulating of form fields using an XML file. You can associate an XML file with a form set, so that when you open a form in the form set, some of the fields in the form get prepolulated.
Prefill XML file is specified using the dataRef parameter of the URL of the form set. The dataRef parameter specifies absolute path of the data XML file that is merged with the form set.
For example, you have three forms (form1, form2, and form3), in the form set with the following structure:
form1
field
form1field
form2
field
form2field
form3
field
form3field
Each form has a common named field, named “field” and a uniquely named field called “form<i>field”.
You can prefill this form set using an XML with the following structure:
<?xml version="1.0" encoding="UTF-8" ?>
<formSetRootTag>
<field>common field value</field>
<form1field>value1</form1field>
<form2field>value2</form2field>
<form3field>value3</form3field>
</formSetRootTag>
The XML root tag can have any name, but the element tags corresponding to the fields must have the same name as the field. The hierarchy of the XML must mimic the hierarchy of the form, which means the XML must have corresponding tags for wrapping subforms.
The above XML snippet shows that the prefill XML for the form set is a union of the prefill XML snippets of the individual forms. If certain fields in the different forms have data hierarchy/schema similar to each other, the fields are prefilled with the same values. In this example all three forms are prefilled with the same value for the common field, “field”. This is a simple way to carry data forward from one form to the next. This can also be achieved by binding the fields to the same schema or data ref. If you want to segregate the form set data based on the forms’ schema. This can be achieved by specifying the “data root” attribute of the form, during form set creation (the default value is “/”, which maps to the form set root tag).
In the previous example, if you specify the data roots: “/form1”, “/form2”, and “/form3” respectively for the three forms, you need to use a prefill XML of the following structure:
<?xml version="1.0" encoding="UTF-8" ?>
<formSetRootTag>
<form1>
<field>field value1</field>
<form1field>value1</form1field>
</form1>
<form2>
<field>field value2</field>
<form2field>value2</form2field>
</form2>
<form3>
<field>field value3</field>
<form3field>value3</form3field>
</form3>
</formSetRootTag>
In a form set, the XML defined an XML schema with the following syntax:
<formset>
<fs_data>
<xdp:xdp xmlns:xdp="https://ns.adobe.com/xdp/">
<xfa:datasets xmlns:xfa="https://www.xfa.org/schema/xfa-data/1.0/">
<xfa:data>
<rootElement>
... data ....
</rootElement>
</xfa:data>
</xfa:datasets>
</xdp:xdp>
</fs_data>
<fs_draft>
... private data...
</fs_draft>
</formset>
If there are two forms with overlapping data roots, or the element hierarchy of one form overlaps with the data root hierarchy of another form, in the prefill xml, the overlapped elements’ values are merged. The submit XML has similar structure as the prefill XML, but submit XML has more wrapper tags and some form set context data tags appended at the end.
Syntax rules for creating a prefill XML file:
parent elements:
null
cardinality: [0,1]
submitXML: P
prefillXML: O
children: fs_data
The root element of the form set XML. It is advised to not use this word as the name of the rootSubform of any form in the form set.
parent elements:
formset
cardinality: [1]
submitXML: P
prefillXML: O
children: xdp:xdp/rootElement
The subtree indicates the data of the forms in the form set. The element is optional in prefill XML only if the form set element is not present
parent elements: fs_data/null
cardinality: [0,1]
submitXML: O
prefillXML: O
children: xfa:datasets
This tag indicates the start of HTML5 Form XML. This is added in the submit XML if it is present in the prefill XML or there is no prefill XML. This tag can be removed from the prefill XML.
parent elements: xdp:xdp
cardinality: [1]
submitXML: O
prefillXML: O
children: xfa:data
parent elements: xfa:datasets
cardinality: [1]
submitXML: O
prefillXML: O
children: rootElement
parent elements: xfa:datasets/fs_data/null
cardinality: [0,1]
submitXML: P
prefillXML: O
children: controlled by the Forms in Form set
The name rootElement is just a placeholder. The actual name is picked from the forms used in the form set. The subtree that starts with rootElement contains the data of the fields and subforms inside the Forms in the form set. There are multiple factors that determine the structure of the rootElement and its children.
In prefill XML, this tag is optional, but if it’s missing, the entire XML is ignored.
NAME OF THE ROOT ELEMENT TAG
In case there is a root element in the prefill XML, the name of that element is taken in the submit XML as well. In cases where there is no prefill xml, the name of the rootElement is the name of the Root Subform of the first form in the form set that has a dataRoot property set to “/”. If there is no such form, then the rootElement name is fs_dummy_root, which is a reserved keyword.
AEM Forms app allows field workers to synchronize their mobile devices with an AEM Forms server and work on their tasks. The application works even when the device is offline by saving data locally on the device. Using annotation features, such as photographs, field workers can provide accurate information to integrate into the business processes.
For more information on AEM Forms app, see AEM Forms app.
The following data patterns are not fully supported in Form set:
Pattern not fully supported in Form set | Example |
Input size and pattern size mismatch | When pattern= num{z,zzz} And input= 12,345 or 1,23 |
Picture Clause Patterns with brackets "(" ")" | num{(zz,zzz)} |
Multiple data patterns | num{zz,zzz} | num{z,zzz,zzz} |
Shorthand patterns | num.integer{}, num.decimal{}, num.percent{}, or num.currency{} |