Tag Archives: AX 2012
Sales return order line registration in D365FO and AX 2012
Introduction: Sales return order line registration in X++ Details: Consider SalesReturnOrderRegisterLine is the table where records are with SalesLine referenced. If we are required to register serialized items than salesReturnOrderRegisterLine.inventSerialId will be considered and if item referred with batch then salesReturnOrderRegisterLine.inventBatchId will be considered. public static void inventoryRegistration(SalesId _salesId) { SalesReturnOrderRegisterLine salesReturnOrderRegisterLine; SalesLine salesLine; TmpInventTransWMS tmpInventTransWMS; InventTransWMS_Register inventTransWMS_Register; InventDim inventDim; InventTrans inventTrans; VendPackingSlipTrans vendPackingSlipTransLoc; InventTransOrigin inventTransOrigin; while select salesReturnOrderRegisterLine where salesReturnOrderRegisterLine.SalesId == _salesId { salesLine = SalesReturnOrderRegister::updateDispositionCode(salesReturnOrderRegisterLine.InventTransId); inventTransWMS_Register = InventTransWMS_Register::newStandard(tmpInventTransWMS); select firstonly inventTrans where inventTrans.StatusReceipt == StatusReceipt::Ordered exists join inventTransOrigin where inventTransOrigin.RecId == inventTrans.InventTransOrigin && inventTransOrigin.InventTransId == salesLine.InventTransId && inventTransOrigin.ReferenceId == _salesId; tmpInventTransWMS.clear(); tmpInventTransWMS.initFromInventTrans(inventTrans); tmpInventTransWMS.InventQty = salesReturnOrderRegisterLine.SalesQty; tmpInventTransWMS.LineNum = int642int(salesLine.LineNum); inventDim = salesLine.inventDim(); inventDim.inventSerialId = salesReturnOrderRegisterLine.inventSerialId; inventDim.inventBatchId = salesReturnOrderRegisterLine.inventBatchId; tmpInventTransWMS.InventDimId = InventDim::findOrCreate(inventDim).inventDimId; tmpInventTransWMS.ItemId = salesLine.ItemId; inventTransWMS_Register.writeTmpInventTransWMS(tmpInventTransWMS, inventTrans, InventDim::find(tmpInventTransWMS.InventDimId)); if (!inventTransWMS_Register.updateInvent(salesLine)) { throw error(“Error during sales return order registration”); } } } Consider SalesReturnOrderRegister is the class which has below static methods public static SalesLine updateDispositionCode(InventTransId _inventTransId) { SalesLine salesLine = SalesLine::findInventTransId(_inventTransId, true); ReturnDispositionCode returnDispositionCode; SalesReturnOrderRegister::runPreReturnOrderRegisterLine(salesLine); salesLine.ReturnDispositionCodeId = returnDispositionCode.DispositionCodeId; salesLine.update(); return salesLine; } public static void runPreReturnOrderRegisterLine(SalesLine _salesLine) { InventTransOriginId salesLineInventTransOriginId; InventTransOriginId reservationLineInventTransOriginId; SalesLine reservationLine; ReturnDispositionCode returnDispositionCode; if (_salesLine.ReturnStatus == ReturnStatusLine::Awaiting) { if (!_salesLine.ReturnAllowReservation && _salesLine.isStocked()) { SalesLine::changeReturnOrderType(_salesLine.InventTransId); _salesLine = SalesLine::findInventTransId(_salesLine.InventTransId, true); } select firstOnly returnDispositionCode where returnDispositionCode.DispositionAction == DispositionAction::Credit; _salesLine.ReturnDispositionCodeId = returnDispositionCode.DispositionCodeId; _salesLine.update(); } else if (_salesLine.ReturnStatus == ReturnStatusLine::Registered) { select forupdate firstonly reservationLine where reservationLine.InventRefTransId == _salesLine.InventTransId; if (reservationLine || _salesLine.qtyMarked()) { if ((_salesLine.returnDispositionCode().DispositionAction == DispositionAction::ReplaceScrap || _salesLine.returnDispositionCode().DispositionAction == DispositionAction::ReturnToCust || _salesLine.returnDispositionCode().DispositionAction == DispositionAction::Scrap)) { if (reservationLine.SalesQty == reservationLine.RemainSalesPhysical) { reservationLineInventTransOriginId = InventTransOriginSalesLine::findInventTransOriginId(reservationLine.DataAreaId, reservationLine.InventTransId); salesLineInventTransOriginId = InventTransOriginSalesLine::findInventTransOriginId(_salesLine.DataAreaId, _salesLine.InventTransId); InventTransOrigin::deleteMarking(salesLineInventTransOriginId, reservationLineInventTransOriginId, -_salesLine.QtyOrdered); reservationLine.delete(); } } else { throw error(“@SYS332911”); } } } } Thanks for reading and stay connected with us for more updates!!! Jagdish Solanki | Senior Technical Consultant | CloudFronts Business Empowering Solutions Team “Solving Complex Business Challenges with Microsoft Dynamics 365 & Power Platform”
How to export projects layerwise in Microsoft Dynamics AX 2012
Introduction: How to export projects layerwise (usr, cus, var, etc.) in Microsoft Dynamics AX 2012? Details: Here, we will see how we can export the projects from AX 2012. Now It’s very easy to do so. We need to create a class or job in the respective environment and just need to do run. static void exportProjects(Args _args) { #AotExport TreeNodeIterator tni; ProjectNode projectNode; int exportFlag; Dialog dialog = new Dialog(); DialogField folderName; DialogField projectDefinitionOnly; DialogField exportFromLayer; DialogField projectType; UtilEntryLevel layer; SysExcelApplication application; SysExcelWorkbooks workbooks; SysExcelWorkbook workbook; SysExcelWorksheets worksheets; SysExcelWorksheet worksheet; SysExcelCells cells; SysExcelCell cell; SysExcelFont font; int row; CustTable custTable; str fileName; fileName = “D:\\Backup XPOs.xlsx”; //By specifying the directly, we will get the list of exported projects //Excel Part…………………………………………………………………… dialog.addText(“This will export all projects (shared or private) that exist in a selected model.”); projectType = dialog.addFieldValue(enumStr(ProjectSharedPrivate), ProjectSharedPrivate::ProjShared); projectDefinitionOnly = dialog.addField(extendedTypeStr(NoYesId), ‘Project Definition Only’); folderName = dialog.addField(extendedTypeStr(FilePath)); exportFromLayer = dialog.addField(enumStr(UtilEntryLevel), ‘Projects from layer’); dialog.run(); if (dialog.closedOk()) { if (!folderName.value()) throw error(“Missing folder”); exportFlag = #export; if (projectDefinitionOnly.value()) exportFlag += #expProjectOnly; layer = exportFromLayer.value(); switch (projectType.value()) { case ProjectSharedPrivate::ProjPrivate: tni = SysTreeNode::getPrivateProject().AOTiterator(); break; case ProjectSharedPrivate::ProjShared: tni = SysTreeNode::getSharedProject().AOTiterator(); break; } projectNode = tni.next() as ProjectNode; while (projectNode) { if (projectNode.AOTLayer() == layer && projectNode.name() like “CFS*”) //if [like] specifies, system will export the projects which names starts with CFS { projectNode.treeNodeExport(folderName.value() + ‘\\’ + projectNode.name() + ‘.xpo’, exportFlag); row++; } projectNode = tni.next() as ProjectNode; } info(“Projects Exported Successfully & Exported Projects List to Excel Sheet”); } else warning(“No action taken…”); } After running the class it will prompt as below. After that select the directory where to export all projects and select the layer from which layer all projects should be exported. Thanks for reading!!!
What is Kernel Hotfix and Application Hotfix in Microsoft Dynamics AX 2012?
Introduction: In this blog, we will see what includes in Kernel Hotfix and Application Hotfix in Microsoft Dynamics AX 2012. Details: 1. Kernel Hotfix: · This hotfix updates Microsoft dlls. E.g. update are the executable files (ax32.exe, ax32serv.exe) and assemblies (Microsoft.Dynamics.AX.*.dll) · There are no code-level changes. · This hotfix required to install at all the client PCs & Servers, where any of the components of AX is installed. · A kernel fix is always cumulative. 2. Application Hotfix: · This type of hotfixes affects code development done by partners. · Updates in the SYP, GLP, FPP & SLP layers (the layers reserved for Microsoft code). These changes are made in the AX model store in AX 2012 and later versions · An application fix is NOT cumulative.
Error ‘Cannot create another system semaphore’ while starting the AX 2012 AOS service
Introduction: While starting the AOS service if you face above error then check 2 things, Check your System log as mention in error (Event Viewer-> Windows Log -> System) it will give you error ‘Cannot create another system semaphore’. Also, Check your Application Log (Event Viewer -> Windows Log -> Application). Cause: This error means simply means your AX 2012 Kernel version is lower than your Application version. As, the kernel version is lower it does not support your current Timezone version. Solution: Upgrade your AX 2012 kernel version to higher version. Run below script to modify your Timezone version Update SQLSystemVariables set value = 4 where parm = ‘SYSTIMEZONESVERSION’
Cause and Solution for Scribe MSMQ not receiving Message from AX
Issue: Microsoft Message Queuing (MSMQ) service running on Server might be unable to receive messages. Therefore, messages stay in “Waiting to connect” state in the outgoing queue of the sending computers. Cause: Issue occurs on 2 scenarios- During computer start, MSMQ service tries to bind to machine IP for listening which is still not acquired by DHCP. This might happen when DHCP takes some time acquiring IP due to any network latency or service start timing between DHCP and MSMQ. In this case MSMQ starts listening to the loopback address i.e. 127.0.0.1. DHCP acquired IP correctly and MSMQ listening on that IP as well. However, at some later point, DHCP IP renewal happens and now machine IP is different from the last one. In this case MSMQ is still listening on the older IP. So, when a new message comes for any old IP, it is never seen by MSMQ service. Verify Scenario: In Command Prompt, type following command and check the result netstat –abno | findstr 1801 If the system is facing this problem, output resembles the following in first scenario: TCP 127.0.0.1:1801 0.0.0.0:0 LISTENING xxxx TCP [::1]:1801 [::]:0 LISTENING xxxx Output resembles the following in second scenario: TCP y.y.y.y:1801 0.0.0.0:0 LISTENING xxxx where, y.y.y.y is the IP address which MSMQ port is listening to but this is different from the IP it should listen to. Resolution: Restart Message Queuing Service If Point 1 don’t resolve the issue, Install this Metadata hotfix. https://support.microsoft.com/en-us/hotfix/kbhotfix?kbnum=2554746&kbln=en-US