Siebel Business Rules Administration Guide > Implementing Rules in Siebel Task-Based UI > Scenario for Using Rules to Provide Dynamic Navigation in a Siebel Task >

Providing Calls to the Rules Engine


This topic is a task in the development process that is listed in Scenario for Using Rules to Provide Dynamic Navigation in a Siebel Task.

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, provide its inputs, and capture its outputs. You must do two configuration tasks:

  • Create a business service that calls the rule module.
  • Include the business service in the task 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 - Task Opportunity

    Project = Rules Call Back

    Cache = TRUE

    Display Name - String Override = Rules Business Call - Task Opportunity

    External Use = TRUE

  3. Expand the Business Service and add a business service method with the following properties to the Rules Business Call - Task Opportunity 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 arguments 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

    vQuality

    String

    Output

    Property

    vQuality

  5. Right-Click on the Rules Business Call - Task Opportunity 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);

          Outputs.SetProperty("vQuality",out);

          return (CancelOperation);

       }

       return (ContinueOperation);

    }

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

    function Rules(Inputs:PropertySet, Outputs:PropertySet)

    {

       try

       {

          //Declare a business service variable.

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

          //Declare the inputs property set variable for Business Rule Service. Declare

          //child and grandchild property sets that build the

          //hierarchical structure of the BusCompList input property.

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

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

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

          //Declare the outputs property set variable for Business Rule Service.

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

          //Declare the variable that gets the row id of the new lead from the task.

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

          //Declare variables to store results.

          var valResult:chars;

          var TheResult:chars;

          //Use methods to build input property set structure.

          //Setting RuleModuleName to module you wish to call.

          inputs.SetProperty("RuleModuleName", "New Lead");

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

          //setfieldvalue calls to process.

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

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

          //the child business components and fields automatically, instead of passing

          //them all explicitly.

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

          //Build the BusCompList > BusComp > Field hierarchy.

          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);

          // Examine the outputs property set.

          var nChild = outputs.GetChildCount();

          var i = 0;

          var resultType;

          var errorText;

          // If no result, then the derivation passed in this example.

          if (nChild == 0)

          {

             return (ContinueOperation);

          }

          // In this example, you only look for RaiseErrorText and DerivationList

          // because you only used those actions in the New Lead rule module.

          for (i = 0; i < nChild; i++)

          {

             resultType = outputs.GetChild(i).GetType();

             //Process RaiseErrorText result

             if (resultType == "RaiseErrorText")

             {

                errorText = outputs.GetChild(i).GetValue();

                return(CancelOperation);

             }

             // Process DerivationList result.

             if (resultType == "DerivationList")

             {

                var j = 0;

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

                var valList:PropertySet = outputs.GetChild(i);

                var valCount:float = valList.GetChildCount();

                // Look at each Derivation result.

                for (j = 0; j < valCount; j++)

                {

                   valResult = valList.GetChild(j).GetProperty("Result");

                   if (valResult != "Valid")

                   {

                      var val:PropertySet = valList.GetChild(j);

                      var msgCount = val.GetChildCount();

                      var k = 0;

                      for (k = 0; k < msgCount; k++)

                      {

                         TheResult = val.GetChild(k).GetValue();

                      }

                      return (TheResult);

                   }

                }

             }

          }

       }//end try

       catch(e)

       {

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

       }

       finally

       {

       }

    }

    For information and examples of the output property sets, see Output Property Set Schema for Business Rule Service.

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

Finish the task definition to include the new Rules Business Call - Task Opportunity business service.

To include the business service in the task definition

  1. In Siebel Tools, navigate to the Task object and select the Create a Lead task.
  2. Right-click and choose Edit Task Flow to access the task editor. Confirm that the status property of the Create a Lead task is In Progress.
  3. Select the main grid with no steps selected. Right-click in the Multi Value Property Window and choose New Record to add each of the following properties:
    Name
    Data Type
    Access Mode

    varRevenue

    Number

    R/W

    varRowId

    String

    R/W

    ReturnFromRulesEngine

    String

    R/W

  4. Select Opportunity General Info Task View Step. In the Multi Value Property Window, click the Output Arguments tab, then choose New Record to add each of the following output arguments:
    Property Name
    Type
    Business Component
    Field

    varRevenue

    Business Component

    Opportunity

    Revenue

    varRowId

    Business Component

    Opportunity

    Id

    Setting these output arguments allows inputs from the user to be assigned to task properties that are ultimately provided as inputs to the business service.

  5. Select the Call Rules Business Service business service step and right-click to assign the following property values.
    Property
    Value

    Business Service Method

    Rules

    Business Service Name

    Rules Business Call - Task Opportunity

  6. With the Call Rules Business Service business service step selected, click the Input Arguments tab in the Multi Value Property Window. Right-click, then choose New Record to add each of the following input arguments.
    Input Argument
    Type
    Property Name

    vRevenue

    Task Property

    varRevenue

    vRowId

    Task Property

    varRowId

  7. Similarly, add the following output argument to the Call Rules Business Service business service step.
    Property Name
    Type
    Output Argument

    ReturnFromRulesEngine

    Output Argument

    vQuality

  8. Select the condition branch labeled Excellent. Right-click and choose Edit Conditions. Set the parameters as follows, then click Add.
    Compare To
    Operation
    Object
    Value

    Task Property

    All Must Match (Ignore Case)

    ReturnFromRulesEngine

    Excellent

  9. Repeat Step 8 to set the following condition for each of the Very High and Default condition branches:
    Condition Branch
    Compare To
    Operation
    Object
    Value

    Very High

    Task Property

    All Must Match (Ignore Case)

    ReturnFromRulesEngine

    Very High

    Default

    Task Property

    All Must Match (Ignore Case)

    ReturnFromRulesEngine

    Default

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