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) {
if (svcMthdName === "CallValidate") {
$.setReturnValue({err: "", retVal: true});
return;
}
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 psOutArgs = SiebelApp.S_App.NewPropertySet();
if (!svcMthdName) {
$.setReturnValue({err: "", retVal: true});
return;
}
if (svcMthdName === "CallValidate") {
this.CallValidate(psinpargs);
$.callback(this,function(retObj){
psOutArgs = retObj.retVal;
this.CleanUp();
$.setReturnValue({err:false,retVal:psOutArgs});
return;
});
}
}
else {
return SiebelApp.PharmaCallValidatorsvc.superclass.InvokeMethod.call(this, svcMthdName, psinpargs);
}
PharmaCallValidatorsvc.prototype.CallValidate = function (psinpropset) {
var psOutArgs = SiebelApp.S_App.NewPropertySet();
//Some Logic
$.setReturnValue({err:false,retVal:psOutArgs});
};
};
return PharmaCallValidatorsvc;
} ());
}
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);
- 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.
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) {
service.InvokeMethod("CountPDMethod", inPropSet);
$.callback(this,function(retObj){
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) {
if (svcMthdName === " CountPDMethod") {
$.setReturnValue({ err: false, retVal: true });
return;
}
else {
return SiebelApp.PharmaCallValidatorsvc.superclass.CanInvokeMethod.call(this, svcMthdName);
}
};
PharmaCallValidatorsvc.prototype.InvokeMethod = function (svcMthdName, Inputs) {
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") + "'";);
PDBC.ExecuteQuery();
$.callback(this,function(retObj){
PDBC.FirstRecord();
$.callback(this,function(){
var result = PDBC.CountRecords();
Outputs.SetProperty("OutputText",result);
});
});
}
For more information about the methods that this step uses, see the following topics: