Configuring Siebel Open UI > Customizing Siebel Open UI for Siebel Mobile Disconnected > Doing General Customization Tasks for Siebel Mobile Disconnected >

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

  1. Use a JavaScript editor to create a new JavaScript file.
  2. 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:

  3. 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.

  4. Depending on whether you want to make a call from service to service, or to a standalone service, use one of the following methods:
    1. 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);

    1. 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:

Configuring Siebel Open UI Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Legal Notices.