Passing Complex Objects to a Workflow Instance

Last published at: April 27th, 2021

By now you understand that you can pass initial variable/global values to any workflow instance at the start of its execution.  These passed in values will be used to initialize the values of the variables and globals defined in your workflow design. 

FlowWright supports the standard data types for variables and globals, which are:

  • String
  • Number
  • Date

Here is an example of a variable and how it is initialized by passing in an initial value: First, let's say you have variable defined within your workflow definition called "".  Then, when you create a new workflow instance based on the workflow definition, a hashtable of variables and values can be provided to the execute method, as shown below:

But how do you pass more complex objects to a workflow instance?

An example of how this is done is this: let's say we have the following class defined "clsPerson":

If you want to pass an instance of this class to the workflow, you can pass the object by serializing the object to either JSON or XML.  The following code shows the serialization of the object:

Once the object is serialized, the JSON string for the above object will look as follows:

This JSON string can be passed into a variable or global, as shown above in the code.  Inside custom step, the variable or global value can retrieved and deserialized using the following method:

FlowWright's recommendation for passing objects is to do the following: don't pass too much information to the workflow instance.  Because FlowWright tracks every variable through every execution iteration of each step, a workflow instance can increase in size and that can reduce performance when executing workflow instances if you pass large quantities of data.  Instead, we recommend passing just pointers to your data or objects and using these pointers throughout workflow steps to access the necessary data or objects.