public int removevirtualasset() throws RemoteException, MXException { WORemote woRemote = (WORemote)getMbo(); MboRemote newMbo = null; MboSetRemote logSet = null; boolean repairFacilityEnabled = CommonUtil.isRepairFacilityEnabled(woRemote, getMXSession().getMXServerRemote()); String virAsstNbr = this.getString("REMVRASTNUM"); if (virAsstNbr != null) { String remReason = this.getString("REMREASON"); String assetDesc = this.getMbo().getMboSet("VIRASSET").getMbo(0).getString("DESCRIPTION"); String remDriver = this.getString("COMP_RM_DRVR_NP"); String plustRsn = this.getString("PLUSTREASON_NP"); String virAstSerNbr = this.getString("VRSERIALNUM"); String virAstSerNbrI = this.getString("VRSERIALNUMI"); String parentLocation = this.getString("LOCATION"); // String workLoc = null; // String moveToLoc = null; // String curAsset = this.getMbo().getString("ASSETNUM"); // Create the Log Note for Creating the FollowUp WO if (virAsstNbr.length() > 0) { logSet = this.getMbo().getMboSet("WORKLOG"); MboRemote logmbo = logSet.addAtEnd(); if (logmbo != null) { logmbo.setValue("LOGTYPE", "INSTREMOVE"); logmbo.setValue("DESCRIPTION", remReason); String str = ""; if (virAsstNbr.length() > 0) { str += "Removed asset: " + virAsstNbr + "\n" ; str += "Removed asset description: " + assetDesc + "\n" ; str += "Serial No Removed: " + virAstSerNbr + "\n" ; if (virAstSerNbrI.length() > 0) str += "Serial No Installed: " + virAstSerNbrI + "\n"; } logmbo.setValue("DESCRIPTION_LONGDESCRIPTION", str); } } if ((repairFacilityEnabled) && (woRemote != null) && ((woRemote.isNull("repairfacility")) || (woRemote.isNull("repfacsiteid")))) { clientSession.loadDialog("createWOWithRepFacility"); } else // Create the FollowUp WO { newMbo = woRemote.createWorkorder(getMbo().getThisMboSet(),null,false); } //DR 2193 by Eric. Get the values of Original WO for removed ProblemCode, and FailureCode. String OrigWonum = woRemote.getString("WONUM"); MboSetRemote origWOSet = newMbo.getMboSet("ORIGWO"); //MXServer.getMXServer().getMboSet("workorder",getMXSession().getUserInfo()); // newMbo.getMboSet("ORIGWO"); String whereStr = "wonum='"+ OrigWonum +"' "; origWOSet.setWhere(whereStr); origWOSet.reset(); MboRemote origWo = origWOSet.getMbo(0); String problemCode = origWo.getString("PROBLEMCODE"); String failureCode = origWo.getString("FAILURECODE"); String origAssetnum = origWo.getString("ASSETNUM"); //origWo.setFieldFlag("PROBLEMCODE", MboConstants.READONLY,true); //origWo.setFieldFlag("FAILURECODE", MboConstants.READONLY,true); woRemote.setValue("PROBLEMCODE", problemCode,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION ); woRemote.setValue("FAILURECODE", failureCode,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION ); // Set Values to New WO newMbo.setValue("ASSETNUM",virAsstNbr, MboConstants.NOVALIDATION_AND_NOACTION_ALLOWCROSSOVER); newMbo.setValue("SERIALNUM2", virAstSerNbr); newMbo.setValue("WORKTYPE", "CM"); newMbo.setValue("DESCRIPTION", remReason); newMbo.setValue("COMP_RM_DRVR", remDriver,MboConstants.NOACCESSCHECK); newMbo.setValue("PLUSTREASON", plustRsn,MboConstants.NOACCESSCHECK); newMbo.setValue("SERIALNUM", virAstSerNbrI); newMbo.setValue("PROBLEMCODE", "", MboConstants.NOVALIDATION | MboConstants.NOVALIDATION_AND_NOACTION); newMbo.setValue("FAILURECODE", "", MboConstants.NOVALIDATION | MboConstants.NOVALIDATION_AND_NOACTION); // Redmin: Feature #2339, the following line is originally dupllcated, replace it for priority = 9. newMbo.setValue("WOPRIORITY", 9); // newMbo.setValue("WORKLOCATION", moveToLoc); // Set Harvest Location based on parent location if location is RSS if (parentLocation.equalsIgnoreCase("RSS")) newMbo.setValue("LOCATION", "OHY-HRVST",11L); // Set the functional department of new workorder to Asset's department newMbo.setValue("BARTDEPT",newMbo.getMboSet("ASSET").getMbo(0).getString("BARTDEPT")); // Reset the mandatory flags this.getMbo().setFieldFlag("REMVRASTNUM", 128L, false); this.getMbo().setFieldFlag("VRSERIALNUM", 128L, false); this.getMbo().setFieldFlag("VRSERIALNUMI", 128L, false); this.getMbo().setFieldFlag("REMREASON", 128L, false); this.getMbo().setFieldFlag("COMP_RM_DRVR_NP", 128L, false); this.getMbo().setFieldFlag("PLUSTREASON_NP", 128L, false); newMbo.getThisMboSet().save(); super.save(); //Close the sets if (!logSet.isEmpty()) logSet.close(); return Utility.sendEvent(new WebClientEvent("dialogclose", this.app.getCurrentPageId(), null, this.sessionContext)); } else return Utility.sendEvent(new WebClientEvent("dialogclose", this.app.getCurrentPageId(), null, this.sessionContext)); }