Tuesday, November 23, 2010

Launching a Workflow Process from a Business Component

One way to replace business component scripting with more declarative configuration is by using Siebel Workflow. A workflow process can perform many of the same operations that you can configure with eScript. If you want to execute a workflow when a BusComp field is updated, you can invoke it from scripting in the SetFieldValue event of the business component. There is, however, the option of using business component user properties for a completely declarative solution.

An example of using the applet version of the Named Method n user property to invoke a workflow process can be found in Siebel Bookshelf. The same user property is available for business components. An example of a named method declaration follows:

User Property Name: Named Method 1
User Property Value: "MyInvokeWFMehod", "INVOKESVC", "Employee", "Workflow Process Manager", "RunProcess", "'ProcessName'", "'The Do Something Cool Workflow Process'", "'WorkPhone'", "[Work Phone Number]", "'Login'", "[Login Name]", "'RowId'", "[Id]"

In this example, "MyInvokeWFMehod" is the name I give to the named method. "Employee" is the name of the business component. "The Do Something Cool Workflow Process" is the name of the workflow process. After the workflow process name, a series of name-value pairs are additional parameters passed to the workflow. "WorkPhone" and "Login" are process properties of the workflow process. Each process property name can be followed by a bracketed field name or business component expression. "RowId" is a method argument of the Workflow Process Manager business service that passes its value to the "Object Id" process property of the workflow.

Please note that parameter names and literals must be in quotes, despite the fact that the user property arguments are already in quotes, which results in the strange syntax of "'Literal Value'".

Another user property is also usually required to invoke the named method, unless the named method is already invoked by the business component itself. To invoke the named method upon a field being updated, use the On Field Update Invoke n user property. For example:

User Property Name: On Field Update Invoke 1
User Property Value: "Work Phone Number", "Employee", "MyInvokeWFMehod"

When the "Work Phone Number" field of the "Employee" business component is updated, the "MyInvokeWFMehod" named method is invoked, which calls the "RunProcess" method of the "Workflow Process Manager" business service, which acts as a proxy for the "Workflow Process Manager" server component, which executes the "The Do Something Cool Workflow Process" process, using values passed from the business component directly into workflow process properties.

In summary, use the On Field Update Invoke n business component user property together with the Named Method n business component user property and your own workflow process for a completely non-scripted way to add complex logic to the event of updating a business component field.