Retrieving Form Data from Tasks

You can retrieve data from forms that are used within tasks. After you retrieve form data (which is typically the value of fields located within the form), you can programmatically process the data to meet your business requirements. For example, you can retrieve data from a form and then update a network database.

Form data must be in the format of Adobe XML Data Package (XDP) documents, which are XML representation of form data. In XDP, form fields are represented as XML elements. For each form field, a corresponding XML element exists that has the same name as the field name. The contents of the XML element are the contents of the field. For example, a text field named Address has the corresponding XML element Address in the XDP document.

Generally, the order in which fields appear on a form is the same order in which their corresponding elements appear in the XDP document. However, the order does not affect whether data is imported into a form. An XDP document must include the Adobe XML Forms Architecture (XFA) document definitions. Following those definitions is an xdp element, which contains a single xfa:datasets element. The xfa:datasets element contains an xfa:data element, which contains the root element of the form data.

The following mortgage application form is an example of a form that is used within a process task.

The format of the data that is retrieved from the form is XFA-based XML data, as shown in the following example.

<?xml version="1.0" encoding="UTF-8" ?>  
- <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"> 
- <xfa:data> 
- <data> 
    - <Layer> 
        <closeDate>1/26/2007</closeDate>  
        <lastName>Johnson</lastName>  
        <firstName>Jerry</firstName>  
        <mailingAddress>JJohnson@NoMailServer.com</mailingAddress>  
        <city>New York</city>  
        <zipCode>00501</zipCode>  
        <state>NY</state>  
        <dateBirth>26/08/1973</dateBirth>  
        <middleInitials>D</middleInitials>  
        <socialSecurityNumber>(555) 555-5555</socialSecurityNumber>  
        <phoneNumber>5555550000</phoneNumber>  
    </Layer> 
    - <Mortgage> 
        <mortgageAmount>295000.00</mortgageAmount>  
        <monthlyMortgagePayment>1724.54</monthlyMortgagePayment>  
        <purchasePrice>300000</purchasePrice>  
        <downPayment>5000</downPayment>  
        <term>25</term>  
        <interestRate>5.00</interestRate>  
    </Mortgage> 
</data> 
</xfa:data> 
</xfa:datasets>
Note: The name of the service that is invoked when retrieving form data that is associated with a task is TaskManagerService. To create a proxy object that lets you invoke its operations by using a web service, specify the following WSDL definition: http://localhost:8080/soap/services/TaskManagerQueryService?WSDL. (See Invoking LiveCycle using Web Services.)

Summary of steps

To retrieve form data from a task, perform the following tasks:

  1. Include project files.

  2. Create a TaskManager Client API object.

  3. Retrieve the form associated with a task.

  4. Get form data.

Include project files

Include necessary files into your development project. If you are creating a client application using Java, include the necessary JAR files. If you are using web services, make sure that you include the proxy files.

Create a TaskManager Client API object

Before you can programmatically search for process instances, you must create a TaskManager object.

To get form data associated with a task, specify the user name and password value of the user to whom the task is assigned when setting connection properties. For example, to retrieve form data from a task assigned to tony blue, use tony blue’s user name and password. If you specify a user who is not assigned the task, an exception is thrown.

Retrieve the form associated with a task

To retrieve form data from a task, reference the task that contains the form using by using the task identifier. You can determine the task identifier by retrieving tasks that are assigned to a specific user.

After you obtain the task identifier value, you can obtain the form that is associated with the task.

Get form data

When you obtain the form, you can retrieve form data. The result is XFA-based XML data that contains form field values and other metadata, such as task identifier value.

Retrieve form data from tasks using the Java API

Retrieve form data from tasks by using the Java API:

  1. Include project files

    Include client JAR files, such as adobe-taskmanager-client-sdk.jar, in your Java project’s class path.

  2. Create a TaskManager Client API object

    • Create a ServiceClientFactory object that contains connection properties.

    • Create a TaskManager object by invoking the TaskManagerClientFactory object’s static getTaskManager method and passing the ServiceClientFactory object.

  3. Retrieve the form associated with a task

    • Create a TaskInfo object that contains task information by invoking the TaskManager object’s getTaskInfo method and passing the task identifier. You can determine the task identifier by retrieving tasks that are assigned to a specific user. (See Retrieving Tasks Assigned to Users.)

    • Retrieve a list of task items that includes the form by invoking TaskInfo object’s getTaskItems method. This method returns an array of FormInstance objects.

    • Get the form identifier value by invoking the FormInstance object’s getFormInstanceId method (this FormInstance object is in the first element in the array of FormInstance objects). This method returns a long value that specifies the form identifier value.

    • Get the form used in the task by invoking the TaskManager object’s getFormInstanceForTask method and passing the following values:

      • The task identifier value that specifies the task (use the same value that was passed to the getTaskInfo method).

      • The form identifier value (the value returned by the getFormInstanceId method).

      • A boolean value that specifies whether to retrieve form data (for this task, specify true).

      The getFormInstanceForTask method returns a FormInstance object that contains form data.

  4. Get form data

    • Get form data by invoking the FormInstance object’s getDocument method. This method returns a com.adobe.idp.Document object that contains the data.

    • Save the data to an XML file by invoking the com.adobe.idp.Document object’s copyToFile method and passing a java.io.File object that specifies the XML file.

Retrieve form data from tasks using the web service API

Retrieve form data from tasks by using the web service API:

  1. Include project files

    • Create a Microsoft .NET client assembly that consumes the TaskManager service WSDL. To create a proxy object that lets you invoke its operations by using Base64 encoding, specify this WSDL definition:

      http://localhost:8080/soap/services/TaskManagerService?WSDL
    • Reference the Microsoft .NET client assembly.

  2. Create a TaskManager Client API object

    • Using the Microsoft .NET client assembly, create a TaskManagerServiceService object by invoking its default constructor.

    • Set the TaskManagerServiceService object’s Credentials data member with a System.Net.NetworkCredential value that specifies the user name and password value.

  3. Retrieve the form associated with a task

    Get the form used in the task by invoking the TaskManager object’s getFormInstanceForTask method and passing the following values:

    • The task identifier value that specifies the task

    • A System.Boolean value that specifies whether the task identifier was specified

    • The form identifier value

    • A System.Boolean value that specifies whether the form identifier was specified

    • A System.Boolean value that specifies whether to retrieve form data (for this task, specify true)

    • A System.Boolean value that specifies whether the previous parameter was specified (for this task, specify true)

    The getFormInstanceForTask method returns a FormInstance object that contains form data.

  4. Get form data

    • Get form data by getting the value of the FormInstance object’s document data member. This data member returns a BLOB instance that contains form data.

    • Save the data to an XML file by creating a System.IO.FileStream object by invoking its constructor and passing a string value that represents the XML file location.

    • Create a byte array that stores the data content of the BLOB object. Populate the byte array by getting the value of the BLOB object’s binaryData data member.

    • Create a System.IO.BinaryWriter object by invoking its constructor and passing the System.IO.FileStream object.

    • Write the contents of the byte array to the XML file by invoking the System.IO.BinaryWriter object’s Write method and passing the byte array.

// Ethnio survey code removed