Using Custom Siebel Business Services
This topic describes how to call a Siebel business service that you customize. You must configure Siebel Open UI to register this business service before Siebel Open UI can call it.
To use custom Siebel business services
- Use a JavaScript editor to create a new JavaScript file. 
- Register your custom business service. You add the following code: - var inputObj = {}; inputObj[oconsts.get("DOUIREG_OBJ_NAME")]= "business_service"; inputObj[oconsts.get("DOUIREG_SRVC_NAME")] = "class"; SiebelApp.S_App.GetModel().ServiceRegistry(inputObj);- where: - business_service identifies the name of a custom business service. 
- class identifies the JavaScript class that the custom business service references. - For example: - if (typeof (SiebelApp.PharmaCallValidatorsvc) === "undefined") { SiebelJS.Namespace('SiebelApp.PharmaCallValidatorsvc'); var oconsts = SiebelApp.Offlineconstants; var inputObj = {}; inputObj[oconsts.get("DOUIREG_OBJ_NAME")]= "LS Pharma Validation Service"; inputObj[oconsts.get("DOUIREG_SRVC_NAME")] = "PharmaCallValidatorsvc"; SiebelApp.S_App.GetModel().ServiceRegistry(inputObj); SiebelApp.PharmaCallValidatorsvc = (function () { function PharmaCallValidatorsvc() { SiebelApp.PharmaCallValidatorsvc.superclass.constructor.call(this); } SiebelJS.Extend(PharmaCallValidatorsvc, SiebelApp.ServiceModel);- For more information about the methods that this step uses, see the following topics: 
 
- Use CanInvokeMethod to determine if Siebel Open UI can call your custom business service method. - For example, the following code determines if Siebel Open UI can call the CallValidate business service method: - PharmaCallValidatorsvc.prototype.CanInvokeMethod = function (svcMthdName) { var currRetValue={err:false}, retObj; if (svcMthdName === "CallValidate") { currRetValue={ err: false, retVal: true }; return currRetValue; } else { return SiebelApp.PharmaCallValidatorsvc.superclass.CanInvokeMethod.call(this, svcMthdName); } };- For more information about the methods that this step uses, see CanInvokeMethod Method. 
- Depending on whether you want to make a call from service to service, or to a standalone service, use one of the following methods: - To make a call from one service to another service, use InvokeMethod. This method will call your custom business service method. - For example, the following code calls the CallValidate business service method: - PharmaCallValidatorsvc.prototype.InvokeMethod = function (svcMthdName, psinpargs) { var currRetValue={err:false}, retObj; var psOutArgs = SiebelApp.S_App.NewPropertySet(); if (!svcMthdName) { currRetValue=({err: "", retVal: true}); return currRetValue; } if (svcMthdName === "CallValidate") { retObj=this.CallValidate(psinpargs); psOutArgs = retObj.retVal; this.CleanUp(); currRetValue=({err:false,retVal:psOutArgs}); return currRetValue; } else { return SiebelApp.PharmaCallValidatorsvc.superclass.InvokeMethod.call(this, svcMthdName, psinpargs); } } PharmaCallValidatorsvc.prototype.CallValidate = function (psinpropset) { var currRetValue={err:false}, retObj; var psOutArgs = SiebelApp.S_App.NewPropertySet(); //Some Logic currRetValue=({err:false,retVal:psOutArgs}); return currRetValue; }; }; return PharmaCallValidatorsvc; } ()); }
- To make a call to a standalone service use the InvokeMethod method. Use the Client- Service Call method to customize the disconnected mobile client. This allows a service call to be made from the client, typically from a physical model. - The call from any other service file must be done as follows: - var service = SiebelApp.S_App.GetService("LS Pharma Validation Service");var outputSet = service.Invoke("CallValidate", psPropertySet);- For example, the following code enables you to display the total number of products detailed in the tooltip. This would be the call from the physical model: - var service = SiebelApp.S_App.GetService("LS Pharma Validation Service"); var inPropSet = SiebelApp.S_App.NewPropertySet(); if (service) { retObj=currRetValue=service.InvokeMethod("CountPDMethod", inPropSet); var outPropSet = retObj.retVal; }- In online mode, the call is to the standalone business service in a server, whereas in offline mode, this invokes the standalone offline business service code. - For example, the following code is for the Sample Offline service: - PharmaCallValidatorsvc.prototype.CanInvokeMethod = function (svcMthdName) { var currRetValue={err:false}, retObj; if (svcMthdName === " CountPDMethod") { currRetValue={ err: false, retVal: true }; return currRetValue; } else { return SiebelApp.PharmaCallValidatorsvc.superclass.CanInvokeMethod.call(this, svcMthdName); } }; PharmaCallValidatorsvc.prototype.InvokeMethod = function (svcMthdName, Inputs) { var currRetValue={err:false}, retObj; var psOutArgs = CCFMiscUtil_CreatePropSet(); if (svcMthdName === " CountPDMethod") { var BO = SiebelApp.S_App.GetBusObject("Pharma Professional Call - Mobile"); var PDBC = BO.GetBusComp("Pharma Call Products Detailed"); PDBC.SetSearchExpr( "[Activity Id] = '" + Inputs.GetProperty("Id") + "'";); retObj=currRetValue=PDBC.ExecuteQuery(); retObj=currRetValue=PDBC.FirstRecord(); var result = PDBC.CountRecords(); Outputs.SetProperty("OutputText",result); }
 
For more information about the methods that this step uses, see the following topics: