/// create/Update marking between purhcase order and transfer order /// </summary> /// <param name = "_inventTransId">receipt InventTrans PO</param> /// <param name = "_refInventTransId">Issue InventTrans TO</param> /// <param name = "_qtyToMark">qty</param> public void updateMarking(InventTransId _inventTransId, InventTransId _refInventTransId, Qty _qtyToMark = 0) { Qty qtyToMark; try { TmpInventTransMark tmpInventTransMark; InventTransId issueInventTransId = _inventTransId; InventTransId receiptInventTransId = _refInventTransId; InventTransOriginId receiptInventTransOriginId = InventTransOrigin::findByInventTransId(receiptInventTransId).RecId; InventTrans receiptInventTrans = InventTrans::findByInventTransOrigin(receiptInventTransOriginId); InventTransOriginId issueInventTransOriginId = InventTransOrigin::findByInventTransId(issueInventTransId).RecId; InventTrans issueInventTrans = InventTrans::findByInventTransOrigin(issueInventTransOriginId); InventTransMarkCollection collection = TmpInventTransMark::markingCollection( InventTransOrigin::find(receiptInventTransOriginId), receiptInventTrans.inventDim(), receiptInventTrans.Qty); collection.insertCollectionToTmpTable(tmpInventTransMark); select firstonly tmpInventTransMark where tmpInventTransMark.InventTransOrigin == issueInventTrans.InventTransOrigin && tmpInventTransMark.InventDimId == issueInventTrans.InventDimId; if (tmpInventTransMark.RecId != 0) { qtyToMark = issueInventTrans.Qty; tmpInventTransMark.QtyMarkNow = qtyToMark; tmpInventTransMark.QtyRemain -= tmpInventTransMark.QtyMarkNow; Map mapUpdated = new Map(Types::Int64, Types::Record); mapUpdated.insert(tmpInventTransMark.RecId, tmpInventTransMark); TmpInventTransMark::updateTmpMark( receiptInventTransOriginId, receiptInventTrans.inventDim(), -qtyToMark, mapUpdated.pack()); } } catch (Exception::Error) { throw error(strFmt("FailMarkInventtransaction", _refInventTransId)); } }
This blog is contains coding reference related to Microsoft AX 2012 and D365 finance and operations and Power platform
Tuesday, December 13, 2022
D365FO: Inventory marking between purchase order and transfer order
Monday, December 12, 2022
D365FO IDisposable context class
Scenario: pass additional parameter to a method that doesnt have a parametr signature
After the execution of using code block , Dispose method will be called. IDisposible is a singleton instance of a class per session, for example if you open two different tabs and run the code you will get two different instance of the class
class DocTypeFile_CUSTOM_Context implements System.IDisposable { static DocTypeFile_CUSTOM_Context docTypeFileContext; public boolean overrideDefaultDocType = false; public boolean printSalesInvoiceReport; public boolean printSalesConfReport; // public PrintMgmtDocumentType printMgmtDocumentType; public DocuTypeId doucTypeId = strMin(); public void new() { if(docTypeFileContext) { throw error("NestingIsNotSupported"); } docTypeFileContext = this; } public void dispose() { docTypeFileContext = null; } static public DocTypeFile_CUSTOM_Context current() { return docTypeFileContext; } }
/// <summary> /// To handle the report design to print based on caller /// </summary> [ExtensionOf(classStr(SalesInvoiceController))] final class SalesInvoiceController_CUSTOM_Extension { /// <summary> /// choose report design /// </summary> protected void outputReport() { //initalize disposible context class using (var docTypeFileContext = new DocTypeFile_CUSTOM_Context()) { SRSPrintDestinationSettings srsPrintDestinationSettings = formLetterReport.getCurrentPrintSetting().parmPrintJobSettings(); if (srsPrintDestinationSettings.printMediumType() == SRSPrintMediumType::File) { docTypeFileContext.overrideDefaultDocType = true; docTypeFileContext.doucTypeId = "File"; } next outputReport(); } } }
[ExtensionOf(tableStr(DocuType))] final class DocuType_CUSTOM_Extension { static DocuTypeId typeFile() { DocuTypeId docuTypeId; docuTypeId = next typeFile(); DocTypeFile_CUSTOM_Context docTypeFileContext = DocTypeFile_CUSTOM_Context::current(); if(docTypeFileContext && docTypeFileContext.overrideDefaultDocType) { docuTypeId = docTypeFileContext.doucTypeId; } return docuTypeId; } }
Monday, December 5, 2022
Release Number sequence X++
NumberSeq::release(numSeq.parmNumberSequenceCode(), "Number Seq to be released");
NumberSeq::release("@AR26", CustTable.AccountNum);
Subscribe to:
Posts (Atom)