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

Allowing Users to Return Parts


The example in this topic describes how to enable the RMA button so that a user can return a part. To return a part, the user creates a part tracker record, and then clicks the RMA button to create a Return Material Authorization (RMA) record. The work you do to allow a user to return a part is similar to the work you do to allow a user to commit a Part Tracker record. For example, registering the service, calling the CanInvoke method, DoInvoke method, and so on.

You add the code that specifies how to do the RMA return in step Step 4 through Step 10. The rma_return.js file contains this code. To get a copy of this file, see Article ID 1494998.1 on My Oracle Support.

To allow users to return parts

  1. In Windows Explorer, navigate to the following folder:

    INSTALL_DIR\eappweb\PUBLIC\language_code\build_number\scripts\siebel\offline

    For more information about the language_code, see Languages That Siebel Open UI Supports.

  2. Use a JavaScript editor to open the servicecmtparts.js file.
  3. Add the following code to the InvokeMethod method:

    var model= SiebelApp.S_App.GetModel();
    var pBusObj = model.GetBusObject("boName");
    var pBusComp = pBusObj.GetBusComp("bcName");

    This code gets the active business component for the applet that displays the RMA button.

  4. Add the following code. This code declares the objects:

    if (typeof (SiebelApp.commitpartconsumed) === "undefined") {
      SiebelJS.Namespace('SiebelApp.commitpartconsumed');

      var inputArgs = {};
      var oconsts = SiebelApp.Offlineconstants;
      
      inputArgs[oconsts.get("DOUIREG_OBJ_NAME")]="SHCE Service FS Activity Part Movements List Applet - 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")]="commitpartconsumed";
      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={};
      
      inputArgs[oconsts.get("DOUIREG_OBJ_NAME")]="SHCE Service FS Activity Part Movements List Applet - 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")]="commitpartconsumed";
      inputArgs[oconsts.get("DOUIREG_SRVC_MTDH")]="InvokeMethod";
      inputArgs[oconsts.get("DOUIREG_EXT_TYPE")]=oconsts.get("DOUIREG_EXT_TYPEPRE");
      
      SiebelApp.S_App.GetModel().ServiceRegistry(inputArgs);

      inputArgs={};

    For information about the methods that this code uses, see the following topics:

  5. Add the following code. This code calls the CanInvokeMethod method:

      SiebelApp.commitpartconsumed = (function () {
        function commitpartconsumed(pm) {
        }
        var commitObj = new commitpartconsumed();
        commitpartconsumed.prototype.CanInvokeMethod = function (psInputArgs) {
          var psOutArgs = SiebelApp.S_App.NewPropertySet();
          var svcMthdName = "";
          svcMthdName = psInputArgs.GetProperty("MethodName").toString();
          if (svcMthdName === "CommitPartMvmtClient") {
            psOutArgs.SetProperty("Invoked", true);
            psOutArgs.SetProperty("RetVal", true);
            $.setReturnValue({err:false,retVal:psOutArgs});
          }
          
          else if (svcMthdName === "OrderPartsRMA") {
            psOutArgs.SetProperty("Invoked", true);
            psOutArgs.SetProperty("RetVal", true);
            $.setReturnValue({err:false,retVal:psOutArgs});
          }
          else{
            psOutArgs.SetProperty("Invoked", false);
            psOutArgs.SetProperty("RetVal", false);
            $.setReturnValue({err:false,retVal:psOutArgs});
          }
        };

  6. Add the following code. This code calls the InvokeMethod method:

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

    For information about the methods that this code uses, see setReturnValue Method.

  7. Add the code that gets values for the following fields:
    • Product Id
    • Product Name
    • Used Quantity
    • Id
    • Status
    • Asset Number
    • Part Number

      You add the following code:

    commitpartconsumed.prototype.createRMAOrder = function (orderType) {
      var sOrderId;
      var cszOrderId;
      var sAssetNum;
      var sPartNum;
      var sStatus;
      var sProductId;
      var sProductName;
      var sQuantity;
      var sActivityPartMvmtID;
      var pModel;
      var pFSActivityPartsMovementBC;
      var pActionBC;
      var sSR_Id;
      var pServiceRequestBC;
      var pOrderEntry_OrdersBC;
      var pOrderEntry_LineItemBC;
      var errParamArray = [];
      pModel = SiebelApp.S_App.Model;
      var pBusObj = pModel.GetBusObject("boName")
      pFSActivityPartsMovementBC=pBusObj.GetBusComp("bcName");
      $.callback(this,function(retObj){
        sOrderId=retObj.retVal;
        if (utils.IsEmpty(sOrderId)){
          pFSActivityPartsMovementBC.GetFieldValue("");
          var oPsDR_Header:PropertySet = SiebelApp.S_App.NewPropertySet();
          // Cannot use the same property set in GetMultipleFieldValues, must use a different
          // one for the values. The process will not error, but Siebel Open UI will not place
          // the values in the property set.
          var lPS_values:PropertySet = SiebelApp.S_App.NewPropertySet();
          oPsDR_Header.SetProperty("Product Id","");
          oPsDR_Header.SetProperty("Used Quantity","");
          oPsDR_Header.SetProperty("Id","");
          oPsDR_Header.SetProperty("Asset Number","");
          oPsDR_Header.SetProperty("Part Number","");
          $.callback(this,function(retObj){
            sPartNum=retObj.retVal;
            pActionBC = SiebelApp.S_App.GetActiveView().GetActiveApplet().BusComp().ParentBuscomp();
            pActionBC.GetFieldValue("Activity SR Id");
            $.callback(this,function(retObj){
              sSR_Id = retObj.retVal;
              if(sSR_Id==""){
                 //Activity has no associated SR... Hence the operation will be aborted
                SiebelApp.S_App.OfflineErrorObject.SetErrorMsg("IDS_ERR_FS_MISSING_SR", errParamArray);
                $.setReturnValue({err: "IDS_ERR_FS_MISSING_SR", retVal:""});
                return;
              }
            });
          });
        }
      });
    }

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

  8. Add the code that gets the parent business component and the following business components:
    • Service Request
    • Order Entry - Orders
    • Order Entry - Line Items

      This code also determines whether or not a service request is not associated with the activity. If not, then it aborts the operation. You add the following code:

    else{
      pModel = SiebelApp.S_App.Model;
      pServiceRequestBC = pModel.BusObj("Service Request").BusComp("Service Request");
      pOrderEntry_OrdersBC = SiebelApp.S_App.Model.GetBusObj("Service Request").BusComp("Order Entry - Orders");
      pOrderEntry_LineItemBC = pModel.BusObj("Service Request").BusComp("Order Entry - Line Items");
    //CREATE ORDER Header.
      pOrderEntry_OrdersBC.ExecuteQuery();
      $.callback(this,function(retObj){

  9. Add the code that creates the Order Header record and sets the field values. For example, for the Order Type field. You add the following code:

    pOrderEntry_OrdersBC.NewRecord(true);
      $.callback(this,function(retObj){
        sLocaleVal = SiebelApp.S_App.Model.GetLovNameVal(orderType, "FS_ORDER_TYPE");
        pOrderEntry_OrdersBC.SetFieldValue("Order Type", sLocaleVal, true);
        $.callback(this,function(retObj){
          pOrderEntry_OrdersBC.WriteRecord();
          $.callback(this,function(retObj){
            pOrderEntry_OrdersBC.GetFieldValue("Id");
            $.callback(this,function(retObj){
              sOrderItemId=retObj.retVal;
              pOrderEntry_OrdersBC.GetFieldValue("Id");
              $.callback(this,function(retObj){
                m_sOrderHeaderId=retObj.retVal;
                pOrderEntry_LineItemBC.ExecuteQuery();
                $.callback(this,function(retObj){

    For information about the methods that this code uses, see SetFieldValue Method, WriteRecord Method, NewRecord Method.

  10. Add the code that creates the order line item record, commits this record, and sets the value for the Order Item Id field in the active business component. This value is the row Id of the order header record that Siebel Open UI creates. This code sets the field value for each of the following fields:
    • Product
    • Quantity Requested
    • Asset #
    • Part #
    • Product Status Code
    • Order Header Id

      You add the following code:

    pOrderEntry_LineItemBC.NewRecord(true);
      $.callback(this,function(retObj){
        pOrderEntry_LineItemBC.SetFieldValue("Product  Id",  sProductId,  true);
        $.callback(this,function(retObj){
          pOrderEntry_LineItemBC.SetFieldValue("Product",  sProductName,  true);
            $.callback(this,function(retObj){
              pOrderEntry_LineItemBC.SetFieldValue("Quantity  Requested",  sQuantity,  true);
              $.callback(this,function(retObj){
              if(!utils.IsEmpty(sAssetNum)){
                pOrderEntry_LineItemBC.SetFieldValue("Asset  Number",  sAssetNum,  true);
                $.callback(this,function(retObj){
                });
              }
              if(!utils.IsEmpty(sPartNum)){
                pOrderEntry_LineItemBC.SetFieldValue("Part  Number",  sPartNum,  true);
                $.callback(this,function(retObj){
                });
              }
              if(!utils.IsEmpty(sStatus)){
                pOrderEntry_LineItemBC.SetFieldValue("Product  Status  Code",  sStatus,  true);
              $.callback(this,function(retObj){
              });
              }
              pOrderEntry_LineItemBC.GetFieldValue("Id");
              $.callback(this,function(retObj){
                sOrderItemId=retObj.retVal;
                pOrderEntry_LineItemBC.SetFieldValue("Order  Header  Id",  m_sOrderHeaderId,  true);
                $.callback(this,function(retObj){
                  pOrderEntry_LineItemBC.WriteRecord();
                  $.callback(this,function(retObj){
                    pFSActivityPartsMovementBC.SetFieldValue("Order  Item  Id",  sOrderItemId,  true);
                   $.callback(this,function(retObj){
                      pFSActivityPartsMovementBC.WriteRecord();
                      $.callback(this,function(retObj){
                      });
                    });
                  });
                });
              });
            });
          });
        });
      });
    });

  11. Save, and then close the servicecmtparts.js file.
  12. Test your modifications:
    1. Log in to the disconnected client.
    2. Click the Activities tab.
    3. Create an activity, and then click Part Tracker.
    4. Create a part tracker record.
    5. Click the RMA button to create a Return Material Authorization (RMA) record.
    6. Make sure Siebel Open UI creates the RMA record and displays the correct values in the fields of this record, such as the Product Id, Product Name, Used Quantity, Quantity Requested, Asset #, and so on.
Configuring Siebel Open UI Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Legal Notices.