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

Using Custom JavaScript Methods


The example in this topic describes how to call a custom JavaScript method that does not customize a predefined method. Siebel Open UI does not require you to register a custom JavaScript method. Instead, you configure Siebel Open UI to do the following work:

  • Override the InvokeMethod to call your custom method.
  • Override the CanInvokeMethod method to enable or disable your custom method.

The offline_predefined_js_call_example.js file contains the code that this example describes. To get a copy of this file, see Article ID 1494998.1 on My Oracle Support.

To use custom JavaScript methods

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

  3. Get the value of the MethodName argument from the psInputArgs method:

    svcMthdName = psInputArgs.GetProperty("MethodName").toString();

  4. Call the Submit method:

    if (svcMthdName === "Submit") {
       this.Submit();
       $.callback(this, function (retObj) {

    For information, see callback Method.

  5. 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);
          $.setReturnValue({err: "", retVal: psOutArgs});
        }
        else {
          psOutArgs.SetProperty("Invoked", true);
          $.setReturnValue({err: retObj.err, retVal: psOutArgs});
        }
      });
    }

    For information see setReturnValue Method.

    • 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);
        $.setReturnValue({err: "", retVal: psOutArgs});
      }
      return(psOutArgs);
    };

    • 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 psOutArgs = SiebelApp.S_App.NewPropertySet();
      var svcMthdName = "";
      svcMthdName = psInputArgs.GetProperty("MethodName").toString();
      if (svcMthdName === "Submit") {
        psOutArgs.SetProperty("Invoked", true);
        psOutArgs.SetProperty("RetVal", true);
        $.setReturnValue({err: "", retVal: psOutArgs});
      }

    For more information about RetVal, see setReturnValue Method.

  6. 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);
          $.setReturnValue({err: "", retVal: psOutArgs});
        }
        return(psOutArgs);
      };
      pharmacallsvc.prototype.Submit= function (psInputArgs) {
        var psOutArgs = SiebelApp.S_App.NewPropertySet();
        return(psOutArgs);
      };
      return pharmacallsvc;
    } ());

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