Save Web Form Data

You can capture web form data at multiple points in a process, and store it in a database or file system for archiving or auditing purposes. For example, capture a web form snapshot after a user submits a form and then again after a manager approves the form.

The save process isn’t visible to the end user.

How it Works

  • Every web form has a data object associated with it that gets created when you create a form.
  • You use input/output data association to create a snapshot of the web form's data object as a binary system. Create a simple expression that uses a Form.getWebForm function to access the data. You can store the form's data as either a PDF (default) or an image (PNG, JPEG or JPG) file.
  • You configure a service task to consume the data stream. In the service task's input data association, associate the stream data to your service method input parameter.
  • Configure the service task's web service method to write the object's data to a location you select, such as a database or file system.

Form.getWebForm Function

Use the Form function in a simple expression to access the web form’s data stream:

Form.getWebForm(webFormDataObject,[format],[formName], [presentationId])
  • webFormDataObject - Can be a data object or task payload object
  • format (String) - Valid values are PDF or PNG/JPEG/JPG (for image). Defaults to PDF
  • formName (String) - Form associated with the data object. Form name is case sensitive
  • presentationName (String) - optional - Presentation Id to be rendered for the form used

Function Examples

  • Form.getWebform(taskWebFormDataObject, "PDF", "startWebForm")
  • Form.getWebform(taskWebFormDataObject, "PDF", "startWebForm", "8d4913a0-e237-dfc5-0eb5-831ddfb9e543")

Configure Web Form Snapshots

You can configure service tasks and capture snapshots of the web form data, and save them locally as PDF or image files.

To configure web form snapshots:
  1. Configure a process that includes a web form and a service task.

    You can create snapshots for a form start event or a human task that uses a web form. For example, in the process shown below, each service task takes a web form snapshot:

    • First, when the user clicks Submit for the start form
    • Second, when the user clicks Approve for the human task
    Description of snapshot-form1.png follows
    Description of the illustration snapshot-form1.png
  2. Set up an expression for the service task that performs the web form snapshot.
    1. Select the service task, and select Data Associations.
    2. On the input side of the Data Association editor, click the fx (Expressions) icon.
    3. In the Expression Editor, click the Operators tab, expand Form, select the Get WebForm function, and click Insert Into Expression. Note that you can enter Form. in the expression field to trigger an autocompletion that lists the three available formats for the function.
    4. In the expression, insert the data object you want to snapshot, and identify an output format of PDF or image (PNG/JPEG/JPG), and other optional parameters.

      PDF is faster than image generation.

      Note that PDF and images are static (read only), so radio button and video controls will not be rendered. Also, events will not work.

    5. Click Validate.

      This expression creates a binary stream of data you can associate with your service method input parameter.

  3. Optionally, set up a second data association that stores a snapshot file name, which you can use to identify the file in your service method.
  4. Optionally, store the snapshot stream in a base64Binary data object for later use as input in your service task data association.

    This step enables you to store the snapshot in the data object and then save all the form snapshots at once at the end of the process.

    1. Create a base64binary process data object to store the captured data stream.
    2. Populate the data object using the output data association of the start form or human task. This method is executed when the start form is submitted or the human task is acted upon.
    3. Use this process data object in your service task’s input data association.
      Description of snapshot-form3.png follows
      Description of the illustration snapshot-form3.png

      The web form’s data object always contains the form’s latest data. If the same form is editable at multiple process stages, it is useful to store the form data at each level in a different process data object as described in step 4.

  5. Create a web service for the service task that calls a method to write the file.

    Below is an example of the service class implementation with a method that takes the web form data stream and stores the file in a local file system.

    Example Method

    public String mySnap(byte[] content,String name) {
    try {
    String fileName = "/scratch/"+name;
    File file = new File(fileName);
    BufferedOutputStream writer = new BufferedOutputStream(new FileOutputStream(file));
    }catch (Exception ex) {
    return "Done";
  6. Deploy and test the application, submitting and approving the form as needed. Check the location where the web service stored the form data and view the PDF or image files.