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