Server-Side Persistence Pattern

   Journey Manager (JM) The transaction engine for the platform.  |    Form Builder Platform Developer  |  All versions This feature is related to all versions.

The main persistence model for Manager is the XML file. This is stored on the server, sent to the browser when a form is rendered, and sent back to the server when the form is submitted. It is also saved to the server in background save events.

However, there are cases when it may be useful to store information on the server which is not stored in the XML file. Some of these cases include:

  • Storing results from a backend server call, such as an actual credit score. We want to record the actual score, but all we want to send to the form is a pass/fail. We don't want it to be in the XML because we don't want the end-customer to see their actual score, or the reasons why they failed.
  • We want to temporarily store in-progress data that has been used in back-end service calls. This is to ensure that the end-user doesn't "game" the system, by changing the data in the form at different points in the journey.
  • We want to store the results of a back-end service call for auditing or debugging purposes - but it's too much data to inject into the XML.
  • There are probably many other cases.
  • This data could be as simple as a string, or more complex like some JSON or XML.

There is a simple way to store and retrieve arbitrary string data against a transaction using Fluent service calls. Let's look at these in more detail.

Storing Data

You can use the TxnUpdater.setProperty(String name, String value) method to create or update a property value. This is illustrated below:

new TxnUpdater(txn)
    .setProperty("MyProp", "MyValue")
    .update()

Retrieving Data

You can use the TxnQuery class to search for a particular transaction, and then get the Property Map within the Txn value object to retrieve the particular property. This is illustrated below:

Txn txn = new TxnQuery()
    .setSubmitKey() // or similar to find the correct transaction
    .withPropertyMap() // to retrieve the properties
    .firstValue() //to find the first matching transaction
    // The returned txn contains an attribute propertyMap of type Map<String,String>

This is important to note that:

  • Data stored in the Transaction Properties are encrypted and subject to data retention policies, just like XML. (In recent versions of Manager.)
  • In some cases, it may be necessary to store data against a collaboration job rather than an individual transaction.
  • The PropertyQuery service is used for locating configuration properties for Form Versions, Workspaces, etc. This is for static configuration properties, not for per-transaction or runtime properties.
  • It is also possible to use the standard HTTP session to store temporary data. However, this data will not be persisted beyond an individual session. A transaction property is persisted in the database.

Next, learn how to view Transact functions.