How to call a Business Service from a PM/PR file in Siebel Open UI

I was working on a requirement where I had to call a Siebel Business Service from PM/PR files. Oracle Support gave a pretty simple steps to the same. But for each of the Business service to be called had to register it as a user property in the Siebel Application user property. This would need a SRF change every time and was not that easily feasible. So came up with the below practice which avoided the SRF change.

Below are the steps to create call a Business Service from the Siebel PM/PR file.
1. Add the below Application User Property
ClientBusinessServiceN = Business Service Name

Here "N" would be the value in sequence of the application user property ClientBusinessService and Business Service Name is the name of the Business Service to be called.

2. In the PM/PR file add the below code to call the Business Service

// Get the Object for the Business Service. Get the Business Service by passing the Business Service Name
var sBusService = SiebelApp.S_App.GetService("Business Service Name");
if(sBusService)
{
       //Create new property set
var Inputs = SiebelApp.S_App.NewPropertySet();
var Outputs = SiebelApp.S_App.NewPropertySet();
       // Invoke the Business service Method and pass the Inputs
Outputs = sBusService.InvokeMethod("Method Name",Inputs );
       // Get the Outputs/Result Set in a property set
var ResultSet = SiebelApp.S_App.NewPropertySet();
ResultSet = oups.GetChildByType ("ResultSet");
}
else
{
alert("Business Service Not Found");
}

The Above two steps are sufficient to invoke a business service from a PM/PR file.

Now to create a code that will not require addition of user property to the Application for each of the Business Service.

1. Create a JS file as BusService.JS and add the below piece of code

if (typeof (BusService) === "undefined") {
var BusService = {};
BusService.InvokeBusService = function(Inputs)
{
var sBusService = SiebelApp.S_App.GetService("Business Service Manager");
if(sBusService)
{
//Set the Method Name to called to the property set
var Outputs = SiebelApp.S_App.NewPropertySet();
// Invoke the Business service Method and pass the Inputs
Outputs = sBusService.InvokeMethod("Run Process", Inputs );
// Get the Outputs/Result Set in a property set
var ResultSet = SiebelApp.S_App.NewPropertySet();
ResultSet = Outputs.GetChildByType ("ResultSet");
return (ResultSet);
}
else
{
alert("Business Service Not Found");
}

}
}

2. Add the BusService.JS file to Custom_Manifest.xml


siebel/custom/BusService.js                

3. Create a Business service in Siebel Application as below

Business Service Name : Business Service Manager
Business Service Method: Run Process
Business Service Method Arguments
Business Service
Method Name
(both the Arguments are required)

Business Service Server Script

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
var returnVal = CancelOperation;
switch(MethodName)
{
case("Run Process"):
RunProcess(Inputs,Outputs);
break;
default:
returnVal = ContinueOperation;
}
return (returnVal);
}

function RunProcess(Inputs,Outputs)
{
var BS = TheApplication().GetService(Inputs.GetProperty("Business Service"));
if(BS)
{
BS.InvokeMethod(Inputs.GetProperty("Method Name"), Inputs, Outputs);
}
else
{
//Handel when Business service does not exist
}
}

4. Register the Business Service with Application User Property
ClientBusinessServiceN Business Service Manager

Compile the Business service and Application and test it as below.

Run the below lines in the console of the Browser.
Inputs = App().NewPropertySet()
Outputs = App().NewPropertySet()
Inputs.SetProperty("Business Service","Test Business Service");//This is the Business Service to be called
Inputs.SetProperty("Method Name","GetData");//This is the message name to be called
Inputs.SetProperty("Name","Tech-Siebel");//Input argument to the custom business service
Res = BusService.InvokeBusService(Inputs);
Res.GetProperty("Name"); //will show the result in the console

Please leave your comments.




Comments

Popular posts from this blog

Siebel - DeleteRecord Method in eScript

Siebel Business Service Part-4