Business Object

Last published at: May 2nd, 2023

What is a Business Object?

FlowWright business object (BO) is an object that gives real time access to business objects from other systems/application.  Think of it as a proxy for business objects.  Business objects are implemented using a simple interface “deIBusinessObject”. 

Business objects are configured with a class name, namespace and the DLL file they belong to.  Once configured, they become available within the workflow designer for defining objects that are business object type.

After defining these business objects, these business objects can be used within processes to get and set their property values.  By using the step “getBusinessObject”, the business object can be retrieved at runtime and then its properties used within other computations.  Let’s say the “Person1” BO has a property called “age”.  This property can be referenced within other steps such as the “Decision” step to perform a comparison such as the following: int.Parse("cDevBO.Person1.age") == 15

Writing a custom Business Object

A custom BO can be implemented using the interface “deIBusinessObject”.  Below is the sample code the “clsPersonBO” business object.  Let’s say “clsPerson” object exists within your APIs/Code, “clsPerson” object may look at follows:

 public class clsPerson

   {

      public string name { get; set; }

      public int age { get; set; }

      public string result { get; set; }

      public clsPerson(string name, int age, string result)

      {

         this.name = name;

         this.age = age;

         this.result = result;

      }

   }

FlowWright wrapper for this business object may look as follows:

   [boData(boName = "clsPersonBO")]

   public class clsPersonBO : deIBusinessObject

   {

      public object getObject(clsEngineContext oEngineContext, Hashtable oInputParameters)

      {

         clsPerson oPerson = new clsPerson(oInputParameters["name"].ToString(),int.Parse(oInputParameters["age"].ToString()), oInputParameters["result"].ToString());

         return (oPerson);

      }

      public List<string> getInputParameterKeys()

      {

         List<string> oList = new List<string>();

         oList.Add("name");

         oList.Add("age");

         oList.Add("result");

         return (oList);

      }

      public Type getObjectType()

      {

         return (typeof(clsPerson));

      }

      public List<string> getDynamicPropertyList()

      {

         List<string> oList = new List<string>();

         oList.Add("alpha");

         oList.Add("beta");

         return (oList);

      }

      public string getDynamicPropertyValue(clsEngineContext oContext, string key)

      {

         return ("3");

      }

      public bool setDynamicPropertyValue(clsEngineContext oContext, string key, string val)

      {

         try

         {

            File.AppendAllText(@"c:\temp\eventdata\dyna.txt", oContext.businessObject.name + " - " + key + " - " + val + Environment.NewLine);

         }

         catch { }

         return (true);

      }

   }

“Get and Set” dynamic property methods are optional methods that need to be implemented, but all other should be implemented for the interface.

Once the custom BO is built, place the DLL file within the FlowWright’s “bin” folder.

C:\inetpub\wwwroot\cDevWorkflow\bin

Use the auto detect feature to auto configure the BO.

Select “Manage -> Configure” to auto configure the selected business object.

Using the Business Object within a workflow process

First make sure the above described “clsPeronBO” BO is configured within the Business Objects section of FlowWright’s configuration manager.  Create a new process definition called “TestBO Def”.

Next open the new “TestBO Def” definition within the workflow designer.

Using the designer menu, select “Actions -> Manage Business Objects” to define a business object to be used within the process.

Manage Business Objects UI will render within the right pane as follows:

Let’s create a process level Business Object called “Person1” that is type “clsPersonBO”.

Now that the Business Object is defined, let’s start using the BO within the process.  First, is to get the BO using the step “getBusinessObject”.

Click the “getbusinessobject” step to configure its properties:

Click the “Params to the business object” to configure the input parameters to get the business object, as show below:

You can also configure few other properties such as whether to load properties on demand and the time to live (ttl) for business object.  By configuring time to live or ttl, business object will automatically update itself after the expiration period.  So, if you have a BO that has an expiration of 10 minutes, whenever the processes accesses that business object, it will check when the last time the BO was updated, if it has expired, it will refresh itself automatically to provide the latest information to the process.

Since this BO has a property called “age” let’s use that property to make a decision.  Let’s drag a decision step on to the designer canvas and connect to the “getbusinessobject” step.

Let’s use the decision step to figure out if the Person1.age is great than 18 years.  Click the “decision” step and configure the properties. 

Let’s save the changes to the definition and get ready to execute an instance based on this definition.

Navigate to the Workflow Instances menu item and create a new Instance. 

After instance has been executed, the Instance should have a status of “finish”.  Click the “Render” button on the toolbar to render the executed Instance. 

The rendered Instance will look as follows: 

Click the “decision” step to drill down into the step information. 

The decision step should render as follows: 

In reference to the above graphic, the decision step evaluated the expression ‘int.Parse(“cDevBO.Person1.age”) > 18’ and returned a value of “True” for the return value of the step.  

Select the “View->Properties” menu item to view the properties for the step:

Click the little icon next to the condition to view the expression with BO replacement values: