Handling data submitted from a form

This Quick Start describes how to use the Forms service to create a process to use XDP data submitted from a rendered PDF form. The XDP data can be saved to a database, sent to another service for processing, or manipulated and saved for later processing. For more information about the Forms service, see Services Reference for AEM forms.

When using the Forms service, data is submitted as XDP data. The resulting data is converted to XML data (without the XDP data). In the form design, the type of data submitted can be configured. (See Designer Help .) For example, an organization has a process that uses a common PDF form that is rendered to applicants to submit loan requests in North America. Separate groups in the organization handle the loan requests based on the country as follows:

  • Applicants who reside in the United States have loan requests handled by Group A.

  • Applicants who reside in Canada have the loan requests handled by Group B.

In a web browser, applicants fill a PDF form that is rendered by the Forms service. The country that an applicant resides in is determined by the Country field. Users select the country in which they reside using a drop-down list. The drop-down list contains the values Canada and United States .

An application, named handleSubmissionApp, implements the service for the organization. When a user clicks the Submit button in the PDF form, XDP data is sent to a Java servlet. The servlet invokes the handleSubmissionApp service. The service uses the Forms to process the XDP data and in a separate step and saves it to an XML file. The XDP data from an applicant in the United States is saved to the network location \\GroupA_US\loan.xml. The XDP data from an applicant in Canada is saved to the network location \GROUP_B_CAN\loan.xml. To keep the loan request data files unique, a unique numeric string is appended to end of the filename. For example, loan1.xml is created if the loan.xml file exists at the network location.

The handleSubmissionApp application includes a process, named handleFormSubmission, that includes the following items:

  • An input document variable, named xdpXML, that stores the XDP data submitted from the servlet when the Submit button is clicked.

  • An output document variable, named outputXML , that stores the XML data.

  • A processFormSubmission operation (Forms service) that processes the submitted data from a PDF form.

  • Two Write Document operations (File Utilities service) that save the XML data as document values. The location to save the XML depends on whether the applicant selected Canada or United States in the drop-down list.

  • A conditional route that determines the next operation to execute. When the value of the Country field is United States, the Write Document operation executes; otherwise, the Write Document2 operation executes.

The process diagram for the handleFormSubmission process looks like the following illustration:

Note: Conditional routes appear as dotted lines in the process diagrams.
generatePrintedOutput and sendtoPrinter operations.

The following text shows relevant parts of the XDP data for understanding this Quick Start. The data is stored in the <xfa:datasets> element and each element in the XML tree can be accessed in the process. In the example that follows, the applicant resides in the United States:

<?xml version="1.0" encoding="UTF-8"?>  
    <?xfa generator="XFA2_4" APIVersion="3.0.8262.0"?>  
    <xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2009-11-27T19:16:38Z" uuid="1fe71528-34a5-43df-8ad1-7f08126b3698"> 
    ...  
    <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"> 
        <xfa:data> 
            <LoanApp> 
                <Name>Akira Tanaka</Name> 
                <LoanAmount>100000</LoanAmount>  
                <PhoneOrEmail>atanaka@sampleorganization.com</PhoneOrEmail>  
                <Country>United States</Country> 
                <ApprovalStatus>PENDING APPROVAL</ApprovalStatus> 
            </LoanApp> 
        ...  
        <xfa:data> 
        ... 
</xdp:xdp>

Configuration

For the processFormSubmission operation, the following properties are configured to retrieve information from the submitted data:

Route Evaluation

There are routes from processFormSubmission operation to the Write Document and Write Document2 operation. Using an XPath expression, a condition is added to the route to the Write Document operation. The XPath expression evaluates the value in the Country field from the <xfa:data> element in the data. The following condition executes the Write Document operation when the Country field is set to United States:

  • /process_data/formData/xdp/datasets/data/LoanApp/Country = "United States"

    Note: XPath expressions allow you access data in the XML data structure. (See Creating XPath expressions .

Input

  • Submitted Form Data: The xdpXML variable that specifies the XDP data submitted to the operation.

  • Environment Variables: An entry where Variable Name is CONTEXT_TYPE and Value is application/vnd.adobe.xdp+xml is added. The entry specifies the type of file that is submitted.

Form Submission Options

  • Export Data Format: The XML Data item is selected from the list. The item specifies to export the XML data without the <Xfa:datasets> packaging.

Output

  • Result Document: The outputXML variable that contains the XDP data submitted to the operation. The XDP data is saved as XML.

    For the Write Document operation, the following properties are configured to save XML data to a network location:

Input

  • Pathname Pattern: The value of \\GroupA_US\loan.xml is typed. The value specifies the location and name of the PDF document.

  • Document: The outputPDF variable that specifies the content to save as a file.

  • Make Unique : The Append a suffix to the filename to make it unique if it has been used option is selected. The option adds a numeric string to the end of the filename, which ensures the filename is unique.

For the Write Document2 operation, the following properties are configured to save the XML data to a network location:

Input

  • Pathname Pattern: The value of \\GroupB_CAN\loan.xml is typed. The value specifies the location and name of the PDF document.

  • Document: The outputPDF variable that specifies the content to save as a file.

  • Make Unique : The Append a suffix to the filename to make it unique if the filename has been used option is selected. The option adds a numeric string to the end of the filename. Adding a numeric value ensures that the filename is unique.

Other considerations

The form used to submit data must be rendered using Forms service. For example, use the Render PDF Form operation to render a PDF form for submission. You cannot use a PDF form created in Acrobat to submit a form to the Forms service. For a web-based system, consider using a Java servlet. (See Creating Web Applications that Renders Forms in Programming with AEM forms .) The Java servlet can handle the rendering and the submission of the PDF form for users that use the service from a web browser.

Instead of using a Java servlet to invoke the service, consider using a web service to invoke the service. For example, JavaScript can be added to the Submit button to invoke the process. (See the Connecting to a data source topic in Designer Help .)

This Quick start does not describe how to pass the XDP data from a Java servlet to invoke the service. (See Passing data to AEM forms services using the Java API in Programming with AEM forms .)

// Ethnio survey code removed