Modifying Form Data

You can programmatically modify form data that is associated with a specific task. For example, a user has an assigned task, which is either to approve or decline a mortgage application. While the task is sitting in the user queue waiting for the user to perform the task, you can programmatically modify form data. As a result, when the user opens the form in Workspace, the user can view the modified form data.

To modify form data, reference a valid XDP XML data source. Consider the following example mortgage application form.

To modify form data, you require a valid XDP XML data source that corresponds to the form. The following XML represents an XDP XML data source that corresponds to the example mortgage application form.

<?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>

Summary of steps

To modify form data, perform the following tasks:

  1. Include project files.

  2. Create a TaskManager Client API object.

  3. Specify form data.

  4. Specify the form design.

  5. Save the task.

Include project files

Include necessary files into your development project. Because you are creating a client application using Java, then include the necessary JAR files.

Create a TaskManagerService Client API object

Before you can programmatically modify form data, you must create a TaskManager object.

To modify form data associated with a task, specify the user name and the 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 that is not assigned the task, an exception is thrown.

Specify form data

To modify form data, reference a valid XML data source that contains form data. If an element located in the XML data source does not correspond to a field in the form, the element is ignored.

Specify the form design

To modify form data, obtain a form instance that is associated with a task. After you obtain the form instance, specify the XML data source location.

Save the task

Modify the form data by saving the task. When you save the task, specify the task identifier and the form instance that represents the form that contains the modified form data.

Modify form data using the Java API

Modify form data 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 TaskManagerService Client API object

    • Create a ServiceClientFactory object that contains connection properties.

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

  3. Specify form data

    • Create a java.io.FileInputStream object by using its constructor and passing a string value that specifies the location of the XML file that contains form data.

    • Create com.adobe.idp.Document object to store form data by using its constructor and passing the java.io.FileInputStream object.

    • Create a java.io.InputStream object that contains form data by invoking the com.adobe.idp.Document object’s getInputStream method.

    • Create a byte array that is used to store form data. Allocate the size of the java.io.InputStream object to the byte array.

    • Populate the byte array by invoking the java.io.InputStream object’s read method and passing the byte array.

  4. Specify the form design

    • Create a new FormInstance object by invoking the TaskManagerService object’s getEmptyForm method. This represents the form that will be populated with form data and used in the task.

    • Specify the form design to use by invoking the FormInstance object’s setTemplatePath and pass a string value that specifies the location of the XDP file (because the form instance is based on an empty form, the form design must be specified by invoking the setTemplatePath method).

    • Specify the form data by invoking the FormInstance object’s setXFAData method and passing the byte array that contains the form data.

    • Invoke the FormInstance object’s setDocument and pass the com.adobe.idp.Document object that contains form data.

  5. Save the task

    Save the task so that the form that contains the modified data is displayed by invoking the TaskManagerService object’s save method and passing the following values:

    • A long value that specifies the task identifier.

    • The FormInstance object that represents the form.

    This method returns a SaveTaskResult object.

Modify form data using the web service API

Modify form data 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 TaskManagerService 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. Specify form data

    • Create a BLOB object by using its constructor. The BLOB object is used to store form data.

    • Create a System.IO.FileStream object by invoking its constructor and passing a string value that specifies the location of the XML file that contains form data and the mode in which to open the file.

    • Create a byte array that stores the content of the System.IO.FileStream object. You can determine the size of the byte array by getting the System.IO.FileStream object’s Length property.

    • Populate the byte array with stream data by invoking the System.IO.FileStream object’s Read method and passing the byte array, the starting position, and the stream length to read.

    • Create a byte array that is used to store form data. Allocate the size of the java.io.InputStream object to the byte array.

    • Populate the byte array by invoking the java.io.InputStream object’s read method and passing the byte array.

    • Populate the BLOB object by assigning its binaryData property with the contents of the byte array.

  4. Specify the form design

    • 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. Typically the value is the same as the task.

      • 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.

    • Specify the form data by assigning the FormInstance object’s XFAData method with the byte array that contains the form data.

    • Assign the FormInstance object’s document data member with the BLOB object that contains form data.

  5. Save the task

    Save the task so that the form that contains the modified data is displayed by invoking the TaskManagerService object’s save method and passing the following values:

    • A long value that specifies the task identifier.

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

    • The FormInstance object that represents the form.

    This method returns a SaveTaskResult object.