A simple example of instantiation

The following example creates a trivial workflow named HelloWorld1. The objective of this example is not to show the branching structure that you can create in workflow. Rather, the purpose of this exercise is to construct the workflow, trigger the workflow, and examine the workflow in the PolicyCenterWorkflow console. The example keeps the workflow as simple as possible. The workflow consists of the following components:

  • <Context> Workflow Element
  • <Start> Workflow Element
  • Step1
  • Step2
  • DefaultOutcome
  • <Finish> Workflow Element

A Simple ClaimCenter Example

Note: This example uses business entities and rules that apply specifically to the Guidewire ClaimCenter application. However, the particular business objects are not important. What is more important is how you create and instantiate a workflow process.

For the workflow to run and do some work and appear on the workflow console, the example instantiates it from a Claim Update rule. If you attempt to instantiate the workflow from a link or button on a Claim view screen (Claim Summary, for example) the workflow executes but does not update anything. Also, it does not appear in the Workflow console.

To cause updates to happen, the example instantiates the workflow from an Edit screen in ClaimCenter. It then calls a Claim Preupdate Rule in Studio.

To create a simple workflow and instantiate it

  1. Create a HelloWorld1.eti file (in Extensions > Entity) and populate it with the following:
    <?xml version="1.0"?>
    <subtype desc="HelloWorld 1 Example Workflow"
             entity="HelloWorld1" 
             supertype="ClaimWorkflow">
      <typekey desc="Language" name="Language" typelist="LanguageType"/>
    </subtype>
  2. Stop and restart Studio.
  3. Select your new workflow type from the Workflows node. Right-click and select New > Workflow Process.
  4. Create a simple workflow process similar to the following. It does not need to be complex, as it simply illustrates how to start a workflow from the ClaimCenter interface.

Workflow with Step1 flowing to Step2.

Notice that it has a claim symbol set in <Context> Workflow Element.

  1. For Step1, add the following to the Enter block for that step:
    gw.api.util.Logger.logInfo( "HelloWorld1 step 1, step called ClaimNumber " + claim.ClaimNumber)
    Workflow.log( "HelloWorld Step 1", "HelloWorld1 step 1 entered: Claim Number " + claim.ClaimNumber )
  2. For Step2, add the following to the Enter block for that step:
    gw.api.util.Logger.logInfo( "HelloWorld1 step 2, step called ClaimNumber " + claim.ClaimNumber)
    Workflow.log( "HelloWorld Step 2", "HelloWorld1 step 2 entered: Claim Number " + claim.ClaimNumber )
  3. Create a simple Claim Pre-Update rule similar to the following:
    • The rule condition specifies that PolicyCenter instantiates the workflow only if the claim PermissionRequired property is set to fraudriskclaim.
    • The rule action instantiates the HelloWorld1 workflow. It first tests for an existing HelloWorld1 workflow that is not in the completed state and that has the same claim number as the one being updated. If it does not find a matching workflow, then PolicyCenter instantiates HelloWorld1 and logs the information.

Rule Conditions:

claim.PermissionRequired=="fraudriskclaim"

Rule Actions:

gw.api.util.Logger.logInfo( "Entering Pre-Update" )

 var hw_wf = claim.Workflows.firstWhere( \ c -> c.Subtype == "HelloWorld1"
        && (c as entity.HelloWorld1).State !="completed" 
        && (c as entity.HelloWorld1).Claim.ClaimNumber==claim.ClaimNumber)
                                           
if (hw_wf == null) {
  gw.api.util.Logger.logInfo( "## Studio instantiating HelloWorld1 and starting it!" )
  var workflow = new entity.HelloWorld1()   
  workflow.Claim = claim
  workflow.start()
}
  1. Log into ClaimCenter and open any sample claim.
  2. Navigate to the Claim Summary page, then select the Claim Status tab.
  3. Click Edit and set the Special Claim Permission value to Fraud risk.
  4. Click Update. This action triggers the HelloWorld1 workflow.

To view the server console

  1. Navigate to the application server console.
  2. View the logger statements.

To view the Workflow console

  1. Log into ClaimCenter using an administrative account.
  2. Navigate to the Administration tab and select Workflows from the left-side menu.
  3. Click Search in the Find Workflows screen. You do not need to enter any search information. Studio displays a list of workflows, including HelloWorld1.
  4. Select HelloWorld1 from the list and view its details.