Thursday, March 18, 2010

Usage of InvokeServiceMethod() on Calculated Fields

In order to achieve complex requirements, we can invoke Business Service scripts from within the Calculated Fields (in Siebel Business Component).

First of all, I would like to emphasize that each calculated field is evaluated whenever the business component is queried, that means that impact performance. Moreover, scripts aren’t recommended as Siebel Best practices. Anyway, in certain contexts his usage is required.

Technical Configuration

Function:
InvokeServiceMethod (name, method, context, returnProperty)

Description:
Returns the value of the return property from the returnProperty set of the specified business service, after invoking the method with the context.

For Example:

InvokeServiceMethod ("BusServ", "PersonalizationMethod", "I_Id=" + [Id] + "," + "I_Date=" + [Created] ,, "ReturnProperty")

invokes the business service method PersonalizationMethod in business service BusServ, passes it the context I_Id=’Id’,I_Date=’DD/MM/YYYY’, and returns the value set by the business service in the property ReturnProperty.





Following is a sample code snippet (Business Service: BusServ):

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{

switch (MethodName)
{
case "PersonalizationMethod":
Example (Inputs, Outputs);
return (CancelOperation);
break;
default:
return (ContinueOperation);
break;
}
}

Where:

function Example (Inputs, Outputs)
{
var Id = Inputs.GetProperty("I_Id");
var Date = new Date(Inputs.GetProperty("I_Date"));
[...]
Outputs.SetProperty("ReturnProperty", Return);
}

Hope this helps!