September 22, 2014

Invoking Business Service from Calculated Field Expression


Recently I came across a requirement where in I had to enable/disable a Button on a Applet if all the given conditions are met. The conditions were not that straight forward, I had to go to different BCs (from different BOs) to check them.

The solution I found was InvokeServiceMethod calculated field expression (not recommended by Siebel though)

SYNTAX: InvokeServiceMethod ("My Business Service", "MyMethod", "inputArg1=" + [Field Name 1] + "," + "inputArg2=" + [Field Name 2], "outputArg")

What I did was,
1. Create a Calculated Field "Enable Button"
2. In Calculated Value I used InvokeServiceMethod, which calls a Business Service (method) with RowId as input and returns Y or N.
3. Used this Calculated Field in Applet User Property "CanInvokeMethod: EnableButton".

How InvokeServiceMethod works?
It invokes given method of a Business Service with Input Arguments, Calculated field refers output argument as its Value.

InvokeServiceMethod ("Enable Button Business Service", "EnableButtonMethod", "RowId=" + [Id], "outEnableButton")

My BS code would look something like this:


if (MethodName == "EnableButtonMethod")
{
  var strRowId = Inputs.GetProperty("RowId");
  var strResult = CheckConditions(strRowId);
  if (strResult == "Y")
  {
    Outputs.SetProperty("outEnableButton", "Y");
  }
  else
  {
    Outputs.SetProperty("outEnableButton", "N");
  }
}


It is not advised to use InvokeServiceMethod if the Calculated Field is exposed in UI. Business Service gets invoked every time you step off a record.

No comments:

Post a Comment