- Use a JavaScript editor to create a new JavaScript file.
- Register the InvokeMethod and CanInvokeMethod methods. You add the following code:
if (typeof (SiebelApp.pharmacallsvc) === "undefined") {
SiebelJS.Namespace('SiebelApp.pharmacallsvc');
var inputObj = {};
var oconsts = SiebelApp.Offlineconstants;
inputObj[oconsts.get("DOUIREG_OBJ_NAME")] = "Pharma Call Entry Mobile";
inputObj[oconsts.get("DOUIREG_OBJ_TYPE")] = oconsts.get("DOUIREG_OBJ_TYPEAPPLET");
inputObj[oconsts.get("DOUIREG_OBJ_MTHD")] = "CanInvokeMethod";
inputObj[oconsts.get("DOUIREG_SRVC_NAME")] = "pharmacallsvc";
inputObj[oconsts.get("DOUIREG_SRVC_MTDH")] = "CanInvokeMethod";
inputObj[oconsts.get("DOUIREG_EXT_TYPE")] = oconsts.get("DOUIREG_EXT_TYPEPRE");
SiebelApp.S_App.GetModel().ServiceRegistry(inputObj);
inputObj[oconsts.get("DOUIREG_OBJ_NAME")] = "Pharma Call Entry Mobile";
inputObj[oconsts.get("DOUIREG_OBJ_TYPE")] = oconsts.get("DOUIREG_OBJ_TYPEAPPLET");
inputObj[oconsts.get("DOUIREG_OBJ_MTHD")] = "InvokeMethod";
inputObj[oconsts.get("DOUIREG_SRVC_NAME")] = "pharmacallsvc";
inputObj[oconsts.get("DOUIREG_SRVC_MTDH")] = "InvokeMethod";
inputObj[oconsts.get("DOUIREG_EXT_TYPE")] = oconsts.get("DOUIREG_EXT_TYPEPRE");
SiebelApp.S_App.GetModel().ServiceRegistry(inputObj);
SiebelApp.pharmacallsvc = (function () {
function pharmacallsvc(pm) {
}
SiebelJS.Extend(pharmacallsvc, SiebelApp.ServiceModel); //Extending
pharmacallsvc.prototype.InvokeMethod = function (psInputArgs) {
var svcMthdName = "";
var psOutArgs = SiebelApp.S_App.NewPropertySet();
For more information about this code, see the description about the inputObj argument in ServiceRegistry Method. Also see CanInvokeMethod Method and Using Siebel Business Services or JavaScript Services to Customize Siebel CRM Objects.
- Get the value of the MethodName argument from the psInputArgs method:
svcMthdName = psInputArgs.GetProperty("MethodName").toString();
- Call the Submit method:
if (svcMthdName === "Submit") {
retObj=this.Submit();
- Do one of the following:
- If InvokeMethod handles the submit call that you define in Step 4, then you use the following code to set the Invoked property to true:
if (!retObj.err) {
psOutArgs.SetProperty("Invoked", true);
currRetValue=({err: "", retVal: psOutArgs});
}
else {
psOutArgs.SetProperty("Invoked", true);
currRetValue=({err: retObj.err, retVal: psOutArgs});
}
});
return currRetValue;}
- If InvokeMethod does not handle the submit call that you define in Step 4, then you must use the following code to configure Siebel Open UI to set the Invoked property to false. This code is required for any InvokeMethod method that you configure Siebel Open UI to override:
else {
psOutArgs.SetProperty("Invoked", false);
currRetValue=({err: "", retVal: psOutArgs});
}
return(currRetValue);
};
- If the current, overridden CanInvokeMethod method handles the submit call that you define in Step 4, then you must set the Invoked property to true. Siebel Open UI includes the return value in the RetVal property for the method from CanInvokeMethod. You can set this method according to your requirements:
pharmacallsvc.prototype.CanInvokeMethod = function (psInputArgs) {
var currRetValue={err:false}, retObj;
var psOutArgs = SiebelApp.S_App.NewPropertySet();
var svcMthdName = "";
svcMthdName = psInputArgs.GetProperty("MethodName").toString();
if (svcMthdName === "Submit") {
psOutArgs.SetProperty("Invoked", true);
psOutArgs.SetProperty("RetVal", true);
currRetValue=({err: "", retVal: psOutArgs});
}
- If the current, overridden CanInvokeMethod method does not handle the submit call, then use the following code to set the Invoked property to false:
else {
psOutArgs.SetProperty("Invoked", false);
psOutArgs.SetProperty("RetVal", false);
currRetValue=({err: "", retVal: psOutArgs});
}
return(currRetValue);
};
pharmacallsvc.prototype.Submit= function (psInputArgs) {
var psOutArgs = SiebelApp.S_App.NewPropertySet();
return(psOutArgs);
};
return pharmacallsvc;
} ());