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

Registering Methods to Make Sure Siebel Open UI Runs Them in the Correct Sequence


Siebel Mobile disconnected uses a local database, which is a database that resides in the browser that stores the data that Siebel Open UI requires. If Siebel Open UI runs in a Siebel Mobile disconnected environment, and if a method in JavaScript code interacts with this local database, then this method is an asynchronous method, and any method that calls this method is also an asynchronous method. This situation might result in Siebel Open UI running code in an incorrect sequence. For example, it might run section B of the code before it runs section A, but the correct logic is to run section A, and then run section B. This topic describes how to configure Siebel Open UI to call an asynchronous method as if the call occurred in a synchronous environment. This configuration makes sure Siebel Open UI runs the asynchronous method in the correct sequence.

To register methods to make sure Siebel Open UI runs them in the correct sequence

  1. On the client computer, use a JavaScript editor to open the file that includes the business service call that you must modify.

    For more information, see Using Custom JavaScript Methods.

  2. Locate the code that includes the business service call that you must modify.
  3. If the call to any asynchronous method from a business service method must run only one time, then use the callback method and the setReturnValue method.

    For example, you can use the ExecuteQuery and FirstRecord methods. Assume you locate the following code in Step 2:

    business_service.prototype.Submit = function () {
      retObj = bc.ExecuteQuery();
      err = retObj.err;
      if(!err){
        retObj = bc.FirstRecord();
        if(!retObj.err){
          //Do an operation here that sets the return value to bRet
          return({err:false,retVal:bRet});
        }
      }
      else{
        SiebelApp.S_App.OfflineErrorObject.SetErrorMsg("messageKey", errParamArray);
        return({err:true});
      }
    };

    • where business_service identifies the name of the business service that your custom code calls. For example, PharmaCallSubmitsvc.

      For more information, see SetErrorMsg Method, FirstRecord Method and ExecuteQuery Method.

      In this example, you replace the code that you located in Step 2 with the following code:

    PharmaCallSubmitsvc.prototype.Submit = function () {
      bc.ExecuteQuery();
      $.callback(this,function(retObj){
        err = retObj.err;
        if(!err){
          bc.FirstRecord();
          $.callback(this,function(retObj){
            if(!retObj.err){
              //Do an operation here that sets the return value to bRet
              $.setReturnValue({err:false,retVal:bRet});
            }
          });
        }
        else{
          SiebelApp.S_App.OfflineErrorObject.SetErrorMsg("messageKey", errParamArray);
          $.setReturnValue({err:true});
        }
      });
    };

    The callback method and the setReturnValue method in this example configures Siebel Open UI to use the same flow to run this code that it uses when it makes a synchronous call in a connected environment. For information about these methods, see callback Method and setReturnValue Method.

  4. If Siebel Open UI must run the call to any asynchronous method from a business service method more than one time, then use the eachAsyncOp method.

    For example, assume you located the following code in Step 2:

    business_service.prototype.Submit = function () {
      var n;
      for(var i =0;i<n;i++){
        // Code that goes into preExecute
        bc.SetFieldValue(fieldName[i],fieldData[i]);
        // code that goes into postExecute
      }
      retObj = bc.WriteRecord();
      if(!retObj.err){
        //Call code here that sets the return value to bRet
        return ({err:false,retVal:bRet});
      }
      else{
        return ({err:true});
      }
    };

    In this example, you replace the code that you located in Step 2 with the following code:

    PharmaCallSubmitsvc.prototype.Submit = function () {
      var preExecutecall= function(i){
        args[0]=fieldName[i];//send the args while calling the async operation which
        is bc.SetFieldValue here
        args[1]=fieldData[i];
        return args; // arguments returned must always be in an array
      }
      var postExecutecall= function(retObj){
        if(!retObj.err){
        //Do domething using the return value obtained from the async call
        }
      }
      var configObj =
      {execute:bc.SetFieldValue,preExecute:preExecutecall,postExecute:postExecuteca
      ll,iterations:n,executeScope:bc};
      $.eachAsyncOp(this,configobj);
      $.callback(this,function(returnObj){
        if(!retObj.err){
          bc.WriteRecord();
          $.callback(this,function(retObj){
            if(!retObj.err){
              //Call code here that sets the return value to bRet
              $.setReturnValue({err:false,retVal:bRet});
            }
          });
        }
      });
    };

    In this example, Siebel Open UI uses the eachAsyncOp method to call the SetFieldValue method more than one time to set the value for more than one field. For information about these methods, see eachAsyncOp Method and SetFieldValue Method, and WriteRecord Method.

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