Siebel – InvokeServiceMethod() on Calculated Fields
by Prachi SharmaInvokeServiceMethod() is used to invoke Business Services and take values from it in case of Calculated Fields.
I actually wanted to post on something else, but, I guess this has to be a precursor to it.
All of us know of Calculated Fields in Siebel Business Components. I am sure they must have solved some very big problems for you at times, as they have for me. However, not all of us know that we can actually invoke Business Service scripts from within the Calculated Fields, rather than just calling some in built functions or playing around with the other fields in the BC. This functionality enhances the already huge functionality of the Calculated Fields in Siebel.
For demonstration, I will first create a new Dummy Business Service, and then invoke it from BC.
Create a new Business Service in Siebel Tools by the name, “Dummy InvokeServiceMethod Test BS”.
Define a method in this BS, “md_SumVals()”. Following is a sample code snippet:
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
if(MethodName == “md_SumVals”)
{
var num1 = Inputs.GetProperty(“Num1″);
var num2 = Inputs.GetProperty(“Num2″);
var Out_Sum = num1 + “,” + num2;
Outputs.SetProperty(“Out_Sum”, Out_Sum);
return(CancelOperation);
}
return (CancelOperation);
}
Client side BS also works in this case.
This BS is now ready to return the Sum of the two input values in the Output Property, “Out_Sum”.
Now, add a new field, “SumVals” in the BC where this value needs to be exposed. Tick mark the “Calculated” property to TRUE for this field. In the column for Calculated Value, enter the expression:
InvokeServiceMethod(“Dummy InvokeServiceMethod Test BS”,”md_SumVals”,”num1=3, num2=4″, “Out_Sum”)
The general syntax for invoking this method is:
InvokeServiceMethod (“[ServiceName]“, “[MethodName]“, “[InputProp1=val1, InputProp2=val2]“, “[OutputProp]“)
This will now return the sum of the two input numbers. This example can be expanded in a variety of ways for complex Siebel operations.
I would like to emphasize for one and all to minimize scripting since Scripts are not recommended as part of Siebel Best practices. It is very rare that you would run out of all the other options and have to use InvokeServiceMethod on a Calculated Field. The requirement has to be really really complex in this case, I guess!
Related posts:
- Siebel – millisecond dates on Applet I had discussed in my previous posts about invoking a...
- Siebel – ActivateField() split wide open In Siebel, we generally tend to use the fields on...
- Siebel – Make MVG Field required Siebel supports the concept of Multi Valued Fields, or the...
- Siebel – Make MVG Field required – II Hi friends, This is a follow-up post of the post...
- Siebel – getMilliseconds() usage Siebel by default displays all dates in the system accurate...
- Siebel – Fetch Active view properties – III I will discuss a practical example, and the corresponding Inputs...
- Siebel – Left, Right and from the Middle Extracting a sub string from a lengthy string in Siebel....