Configuring Siebel Open UI > Customizing Siebel Open UI for Siebel Mobile Disconnected >

Customizing Siebel Pharma for Siebel Mobile Disconnected Clients


This topic includes an example of customizing Siebel Pharma in Siebel Open UI for display in a Siebel Mobile disconnected client. For more information about the functionality that these customizations modify, see the chapter that describes how to use the Siebel Mobile Disconnected Application for Siebel Pharma in Siebel Mobile Guide: Disconnected.

This topic customizes Siebel Pharma to submit a Pharma Call record depending on whether or not Siebel Open UI already submitted this call. It makes sure Siebel Open UI does not overwrite a call that it already submitted to the Siebel Server. To submit a call in Siebel Pharma, the user must do the following work:

  • Enter all information for the call.
  • Add at least one sample for the call.
  • Get the required signature for the samples that the call includes.
  • Set the status for the call to Planned or Signed.
  • Tap Submit.

Siebel Pharma locks a call after it submits this call, and then the user can no longer edit or update the call. You can modify some of this behavior. For more information about the work you do in this topic, see Process of Customizing Siebel Open UI for Siebel Mobile Disconnected. For more information about the methods that this example uses, see Methods You Can Use to Customize Siebel Mobile Disconnected.

To customize Siebel Pharma for Siebel Mobile Disconnected clients

  1. Create a new JavaScript file.

    You can use any file name that is meaningful to your deployment. For example, you can use a short name that indicates what the business service accomplishes. It is recommended that the file name end with svc.js or service.js. For example, callsvc.js. To get a copy of this file, see Article ID 1494998.1 on My Oracle Support. For more information about the folders you can use to store your customizations, see Organizing Files That You Customize.

  2. Register an asynchronous business component method. You add the following code to the file you created in Step 1:

    var inputArgs = {};
    var oconsts = SiebelApp.Offlineconstants;
    var childBCArrObjs = [];
    inputArgs[oconsts.get("DOUIREG_OBJ_NAME")] = "Pharma Call Entry Mobile";
    inputArgs[oconsts.get("DOUIREG_OBJ_TYPE")] = oconsts.get("DOUIREG_OBJ_TYPEAPPLET");
    inputArgs[oconsts.get("DOUIREG_OBJ_MTHD")] = "CanInvokeMethod";
    inputArgs[oconsts.get("DOUIREG_SRVC_NAME")] = "pharmacallsvc";
    inputArgs[oconsts.get("DOUIREG_SRVC_MTDH")] = "CanInvokeMethod";
    inputArgs[oconsts.get("DOUIREG_EXT_TYPE")] = oconsts.get("DOUIREG_EXT_TYPEPRE");
    SiebelApp.S_App.GetModel().ServiceRegistry(inputArgs);
    inputArgs[oconsts.get("DOUIREG_OBJ_NAME")] = "Pharma Call Entry Mobile";
    inputArgs[oconsts.get("DOUIREG_OBJ_TYPE")] = oconsts.get("DOUIREG_OBJ_TYPEAPPLET");
    inputArgs[oconsts.get("DOUIREG_OBJ_MTHD")] = "InvokeMethod";
    inputArgs[oconsts.get("DOUIREG_SRVC_NAME")] = "pharmacallsvc";
    inputArgs[oconsts.get("DOUIREG_SRVC_MTDH")] = "InvokeMethod";
    inputArgs[oconsts.get("DOUIREG_EXT_TYPE")] = oconsts.get("DOUIREG_EXT_TYPEPRE");
    SiebelApp.S_App.GetModel().ServiceRegistry(inputArgs);

    This code registers the CanInvokeMethod method of the pharmacallsvc business service with the CanInvokeMethod of the Pharma Call Entry Mobile business component. It configures Siebel Open UI to call CanInvokeMethod of the pharmacallsvc business service every time it calls CanInvokeMethod on the business component. For more information, see ServiceRegistry Method and CanInvokeMethod Method.

  3. Add the following code immediately after the code you added in Step 2:

    SiebelApp.pharmacallsvc = (function () {
      function pharmacallsvc(pm) {
      }
      SiebelJS.Extend(pharmacallsvc, SiebelApp.ServiceModel);

    This code adds the pharmacallsvc method to the pharmacallsvc business service.

  4. Specify the logic for your asynchronous method. You add the following code immediately after the code you added in Step 3:

    pharmacallsvc.prototype.CanInvokeMethod = function (psInputArgs) {
      var psOutArgs = SiebelApp.S_App.NewPropertySet();
      var svcMthdName = "";
      var pBusComp = this.GetContext().BusComp();
      svcMthdName = psInputArgs.GetProperty("MethodName").toString();

      if (svcMthdName === "Submit") {
        pBusComp.GetFieldValue("Call Status");
        $.callback(this, function (retObj) {
          var callStatus = retObj.retVal;
          if(callStatus!== "Submitted"){
            psOutArgs.SetProperty("Invoked", true);
            psOutArgs.SetProperty("RetVal", true);
            $.setReturnValue({err: false, retVal: psOutArgs});
          }
          else{
            psOutArgs.SetProperty("Invoked", true);
            psOutArgs.SetProperty("RetVal", false);
            $.setReturnValue({err: false, retVal: psOutArgs});
          }
        });
      }
    };

    This code defines CanInvokeMethod. This method determines whether or not Siebel Open UI can call a method in the current context of the business component. In this example, if the value for the active call record is:

    • Not submitted. CanInvokeMethod returns a value of true, and this code sets the properties to call the CanInvokeMethod of the business service.
    • Submitted. CanInvokeMethod returns a value of false, and this code sets the properties to not call the CanInvokeMethod of the business service.

      This code uses the svcMthdName variable to send a value that indicates whether or not Siebel Open UI submitted the record. It sends this value to the code that you define in Step 5.

      For information about the methods that this step uses, see setReturnValue Method, GetFieldValue Method, and callback Method.

  5. Add the following code immediately after the code you added in Step 4:

    pharmacallsvc.prototype.InvokeMethod = function (psInputArgs) {
      var svcMthdName = "";
      var psOutArgs = SiebelApp.S_App.NewPropertySet();
      svcMthdName = psInputArgs.GetProperty("MethodName").toString();
      if (svcMthdName === "Submit") {
        this.Submit();
        $.callback(this, function (retObj) {
          psOutArgs.SetProperty("Invoked", true);
          $.setReturnValue({err: false, retVal: psOutArgs});
        });
      }
    };

    This code configures Siebel Open UI to run InvokeMethod on the business service if the svcMthdName variable that you defined in Step 4 contains a value of Submit.

  6. Define the method that includes your customization logic. You add the following code immediately after the code you added in Step 5:

    pharmacallsvc.prototype.Submit = function () {
      var model= SiebelApp.S_App.GetModel();
      var pBusObj = model.GetBusObject("boName");
      var pBusComp = pBusObj.GetBusComp("bcName");
      var now = new Date();
      var strStatusField = pBusComp.GetUserProperty("Status Field");
      var pickName =     SiebelApp.S_App.GetActiveView().GetActiveApplet().GetControl("Status").
        GetPickApplet();
        pBusComp.SetFieldValue(strStatusField, "submit", true);
      $.callback(this, function (retObj) {
        pBusComp.WriteRecord();
        $.callback(this, function (retObj) {
        });
      });
    }

    This code defines the Submit method. It sets the value for the Status field to Submitted. It uses the following methods:

  7. Test your modifications:
    1. Tap Calls on the application banner to display the Calls list.
    2. Tap a call in the list that you know you have not submitted, and then tap Submit to submit the call.
    3. Verify that Siebel Open UI does the following:
      • Modifies the call status to Submitted.
      • Locks the call
      • Decreases the sample inventory for the sales representative according to the samples and promotional items that the call dropped off
      • Closes the call.
      • Allows you to review, but not edit the call details.
    4. Tap a call in the list that you know you have already submitted, and then tap Submit to submit the call.

      Make sure Siebel Open UI does not overwrite this call. Make sure it displays a dialog box that describes that you have already submitted this call.

Coding Callback Methods

The code in Step 6 is an example of how to code a callback method in an asynchronous environment. For example, it uses the SetFieldValue and the WriteRecord methods, which are asynchronous methods, rather than the SetCommitPending method, which is a synchronous method. A callback method is a type of JavaScript method that Siebel Open UI sends to method A as a property, and then calls this callback method from method A, where A is any JavaScript method.

If you configure Siebel Open UI to call an asynchronous method, then it is recommended that the next line of code that occurs after this call include a callback method. For example, the following code from Step 4 uses a callback method to handle the asynchronous GetFieldValue method:

pBusComp.GetFieldValue("Call Status");
$.callback(this, function (retObj) {
  var callStatus = retObj.retVal;
  if(callStatus !== "Submitted"){

For more information, see GetFieldValue Method and callback Method.

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