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 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
In Windows Explorer, navigate to the following folder:
AI_INSTALL_DIR\applicationcontainer_external\siebelwebroot\scripts\siebel\offline
Use a JavaScript editor to open the servicecmtparts.js file.
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.
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:
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 currRetValue={err:false}, retObj; var psOutArgs = SiebelApp.S_App.NewPropertySet(); var svcMthdName = ""; svcMthdName = psInputArgs.GetProperty("MethodName").toString(); if (svcMthdName === "CommitPartMvmtClient") { psOutArgs.SetProperty("Invoked", true); psOutArgs.SetProperty("RetVal", true); currRetValue={err:false,retVal:psOutArgs}; } else if (svcMthdName === "OrderPartsRMA") { psOutArgs.SetProperty("Invoked", true); psOutArgs.SetProperty("RetVal", true); currRetValue={err:false,retVal:psOutArgs}; } else{ psOutArgs.SetProperty("Invoked", false); psOutArgs.SetProperty("RetVal", false); currRetValue={err:false,retVal:psOutArgs}; } return currRetValue; };
Add the following code. This code calls the InvokeMethod method:
commitpartconsumed.prototype.InvokeMethod = function (psInputArgs) { var currRetValue={err:false}, retObj; var svcMthdName = ""; var psOutArgs = SiebelApp.S_App.NewPropertySet(); svcMthdName = psInputArgs.GetProperty("MethodName").toString(); if (svcMthdName === "CommitPartMvmtClient") { retObj=currRetValue=this.CommitPartMvmtClient(); psOutArgs.SetProperty("Invoked", true); currRetValue={err:false,retVal:psOutArgs}; } else{ psOutArgs.SetProperty("Invoked", false); currRetValue={err:false,retVal:psOutArgs}; } if (svcMthdName === "OrderPartsRMA") { retObj=currRetValue=this.OrderPartsRMA(); psOutArgs.SetProperty("Invoked", true); currRetValue={err:false,retVal:psOutArgs}; } else{ psOutArgs.SetProperty("Invoked", false); currRetValue={err:false,retVal:psOutArgs}; } return currRetValue; };
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 currRetValue={err:false}, retObj; 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"); sOrderId=retObj.retVal; if (utils.IsEmpty(sOrderId)){ retObj=currRetValue=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",""); sPartNum=retObj.retVal; pActionBC=SiebelApp.S_App.GetActiveView().GetActiveApplet().BusComp().ParentBuscomp(); retObj=currRetValue=pActionBC.GetFieldValue("Activity SR Id"); 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); currRetValue={err: "IDS_ERR_FS_MISSING_SR", retVal:""}; return currRetValue; } } return currRetValue; }
For information about the methods that this code uses, see GetFieldValue Method.
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. retObj=currRetValue=pOrderEntry_OrdersBC.ExecuteQuery();
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:
retObj=currRetValue=pOrderEntry_OrdersBC.NewRecord(true); sLocaleVal = SiebelApp.S_App.Model.GetLovNameVal(orderType, "FS_ORDER_TYPE"); retObj=currRetValue=pOrderEntry_OrdersBC.SetFieldValue("Order Type", sLocaleVal, true); retObj=currRetValue=pOrderEntry_OrdersBC.WriteRecord(); retObj=currRetValue=pOrderEntry_OrdersBC.GetFieldValue("Id"); sOrderItemId=retObj.retVal; retObj=currRetValue=pOrderEntry_OrdersBC.GetFieldValue("Id"); m_sOrderHeaderId=retObj.retVal; retObj=currRetValue=pOrderEntry_LineItemBC.ExecuteQuery();
For information about the methods that this code uses, see SetFieldValue Method, WriteRecord Method, NewRecord Method.
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:
retObj=currRetValue=pOrderEntry_LineItemBC.NewRecord(true); retObj=currRetValue=pOrderEntry_LineItemBC.SetFieldValue("Product Id", retObj=currRetValue=pOrderEntry_LineItemBC.SetFieldValue("Product", sProductName, true); retObj=currRetValue=pOrderEntry_LineItemBC.SetFieldValue("Quantity Requested",sQuantity, true); if(!utils.IsEmpty(sAssetNum)){ retObj=currRetValue=pOrderEntry_LineItemBC.SetFieldValue("Asset Number", sAssetNum, true); } if(!utils.IsEmpty(sPartNum)){ retObj=currRetValue=pOrderEntry_LineItemBC.SetFieldValue("Part Number", sPartNum, true); } if(!utils.IsEmpty(sStatus)){ retObj=currRetValue=pOrderEntry_LineItemBC.SetFieldValue("Product Status Code",sStatus, true); } retObj=currRetValue=pOrderEntry_LineItemBC.GetFieldValue("Id"); sOrderItemId=retObj.retVal; retObj=currRetValue=pOrderEntry_LineItemBC.SetFieldValue("Order Header Id", m_sOrderHeaderId, true) retObj=currRetValue=pOrderEntry_LineItemBC.WriteRecord(); retObj=currRetValue=pFSActivityPartsMovementBC.SetFieldValue("Order Item Id",sOrderItemId, true); retObj=currRetValue=pFSActivityPartsMovementBC.WriteRecord();
Save, and then close the servicecmtparts.js file.
Test your modifications:
Log in to the disconnected client.
Click the Activities tab.
Create an activity, and then click Part Tracker.
Create a part tracker record.
Click the RMA button to create a Return Material Authorization (RMA) record.
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.