Siebel Business Rules Administration Guide > Implementing Rules in Siebel Workflows > Scenario for Using Rules in a Siebel Workflow to Do Batch Processing >

Providing Calls to the Rules Engine


This topic is a task in the development process that is listed in Scenario for Using Rules in a Siebel Workflow to Do Batch Processing.

Now that the rules module has passed a simulation test, the last task is to create and use a business service to call the rule module. You must do two configuration tasks:

  • Create a business service that calls the rule module.
  • Include the business service in the workflow definition.

To create a business service that calls the rule module

  1. In Siebel Tools Object Explorer, select Business Service.
  2. Create a new business service with the following properties:

    Name = Rules Business Call - WF

    Project = Business Rule

    Cache = TRUE

    Display Name - String Override = Rules Business Call - WF

    External Use = TRUE

  3. Expand the Business Service and add a business service method with the following properties to the Rules Business Call - WF business service you created in Step 2:

    Name = Rules

    Display Name - String Override = Rules

  4. Expand the Business Service Method object and add the following business service argument to the Rules business service method you created in Step 3.
    Name
    Data Type
    Type
    Storage Type
    Display Name - String Override

    vRowId

    String

    Input

    Property

    vRowId

  5. Right-Click on the Rules Business Call - WF business service and choose Edit Server Scripts.
  6. Select Service_PreInvokeMethod and enter the following script.

    CAUTION:  All examples of script in this document are written for use with the ST eScript engine. To implement this example, first confirm that you are set to use the ST eScript engine in Siebel Tools. For information on setting Siebel Tools to use the ST eScript engine, see To enable the ST eScript engine for Siebel Tools.

    function Service_PreInvokeMethod (MethodName, Inputs:PropertySet, Outputs:PropertySet)

    {

       if (MethodName == "Rules")

       {

          var out:chars = Rules(Inputs, Outputs);

          return (CancelOperation);

       }

       return (ContinueOperation);

    }

  7. Add the following custom method to the Rules Business Call - WF business service:

    function Rules(Inputs:PropertySet, Outputs:PropertySet)

    {

       try

       {

          //Declare your Service and property sets to build your hierarchical structure.

          var svc:Service = TheApplication().GetService("Business Rule Service");

          var inputs:PropertySet = TheApplication().NewPropertySet();

          var outputs:PropertySet = TheApplication().NewPropertySet();

          var child:PropertySet = TheApplication().NewPropertySet();

          var grandchild:PropertySet = TheApplication().NewPropertySet();

          //Declare the variable that gets the row id of the current opportunity

          var RowIdInput:chars = Inputs.GetProperty("vRowId");

          //Declare variable to store results

          var valResult:chars;

          var TheResult:chars;

          //Use methods to build input property set structure.

          //Setting RuleModuleName to the module to call.

          inputs.SetProperty("RuleModuleName", "Opportunity Batch Processing Rules");

          //Setting PerformAction to "Y" because the rule statements include

          //setfieldvalue calls, which are actions.

          inputs.SetProperty("PerformAction", "Y");

          //Setting GetMoreData to "Y" because you want the rules engine to get all

          //the fields automatically, rather than passing them all explicitly.

          inputs.SetProperty("GetMoreData", "Y");

          //Populate variables to create the BusCompList > business component > field

          //hierarchy that will eventually be provided as the BusCompList input

          //property set to Business Rules Service.

          child.SetType("BusCompList");

          grandchild.SetType("BusComp");

          grandchild.SetProperty("Id", RowIdInput);

          grandchild.SetProperty("Name", "Opportunity");

          child.AddChild(grandchild);

          inputs.AddChild(child);

          //Invoke Business Rule Service.

          svc.InvokeMethod("RunRules", inputs, outputs);

       } //end try

       catch(e)

       {

          TheApplication().RaiseErrorText("Error in the Rules function " + e.toString());

       }

       finally

       {

       }

    }

  8. Navigate back to the Business Services list, select the Rules Business Call - WF business service, and choose Tools > Compile Selected Objects.

Finish the Opportunity Rules Batch Processing workflow process definition to include the new Rules Business Call - WF business service.

To include the business service in the workflow process definition

  1. In Siebel Tools, navigate to the Workflow Process object and select the Opportunity Rules Batch Processing workflow process.
  2. Right-click and choose Edit Workflow Process to access the Process Designer. The status property of the Opportunity Rules Batch Processing workflow process is In Progress.
  3. Select the main grid with no steps selected. With the Process Properties tab selected, right click in the Multi Value Property Window, and choose New Record to add the following process property:
    Name
    In/Out
    Business Object
    Data Type
    Access Mode

    vRowId

    In/Out

    Opportunity

    String

    RW

  4. Select the Call Rules Engine business service step and assign the following values in the Properties window:
    Property
    Value

    Business Service Method

    Rules

    Business Service Name

    Rules Business Call - WF

  5. With the Call Rules Engine business service step selected, click the Input Arguments tab in the Multi Value Property Window. Right-click, then choose New Record to add the following input argument:
    Input Argument
    Type
    Property Name

    vRowId

    Process Property

    vRowId

Siebel Business Rules Administration Guide Copyright © 2007, Oracle. All rights reserved.