Posts

How to Import Records from Excel Using X++ Code in D365FO

  How to Import Records from Excel Using X++ Code in D365FO   Include the below namespace in X++ code it will requires to import Excel. Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange;   In addition to the basic reference, include (Directory and DirectoryUpgrade Packages) X++ Code: Using System.IO; Using OfficeOpenXml; Using OfficeOpenXml.ExcelPackage; Using OfficeOpenXml.ExcelRange; class ReadExcel {   public static void main(Args _args)    {     Int id;     Str Name;      System.IO.Stream stream;       ExcelSpreadsheetName sheet;              FileUploadBuild fileUpload,fileUploadBuild;       DialogGroup dialogUploadGroup;       FormBuildControl formBuildControl;   ...

D365 FO Packing slip using X++ and taking current packing slip record

  D365 FO Packing slip using X++ and taking current packing slip record static void postPackingSlip(Args _args) { SalesFormLetter salesFormLetter; SalesTable salesTable; SalesId salesId = ‘SO00001’; System.Exception error; str strError; CustPackingSlipJour custPackingSlipJour; ;   ttsBegin; try { salesTable = SalesTable::find(salesId);   if (salesTable && salesTable.SalesStatus == SalesStatus::Backorder) { salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip); salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::PackingSlip, AccountOrder::None, NoYes::No, NoYes::No, NoYes::No);     custPackingSlipJour = salesFormLetter.parmJournalRecord(); info(strFmt(‘New Packing Slip #:%1 successfully created for Sales Order #:%2’, custPackingSlipJour.PackingSlipId, custPackingSlipJour.SalesId));   } else { info(strFmt(‘%1 does not exsists or null in the system, please try again!...

Rounding the real value D365 FO using X++

  Rounding the real value D365 FO using X++ To perform a round in AX in real using the function decround.   static void Job1(Args _args) {     int i, ii;     real r = 334.55, r2 = 334.14;     ;       i = decround(r, 0);     ii = decround(r2, 0);       // It shows 335, 334     info(strfmt("%1, %2", i, ii)); }

Read properties of table fields using X++ code

  Read properties of table fields using X++ code static void checkProperties(Args _args) {     DictTable        dictTable;     DictField        dictField;     int              i, cnt;        dictTable = new DictTable(tableNum(CustTable));     cnt = dictTable.fieldCnt();     for (i= 1; i<=cnt;i++)     {         dictField = new DictField(tableNum(CustTable),dictTable.fieldCnt2Id(i));         if (dictField.mandatory())         {             info (strFmt("Field %1 is mandatory.",dictField.label()));         }     } ...

Create a production order for a sales order line using X++ in D365

  Create a production order for a sales order line using X++ in D365 If you want to create a production order for a sales order line, use the following code   static void createProdTableForSalesLine(Args _args) {     SalesLine salesLine = SalesLine::findInventTransId('011748');     ProdTable prodTable;       prodTable.initValue();     prodTable.initFromCaller(salesLine);       prodTable.insert(); }

Create production order in D365FO X++

  Create production order in D365FO   X++ static void   CreateProdOrder(Args _args) {     ProdQty          qty      = 10;     ItemId           item     = 'D0005';       ProdTable        prodtable;     InventTable      inventTable;     InventDim        inventDim;     ;       // Initialize InventTable     inventTable = inventTable::find(item);       // Initialize the base values     prodtable.initValue();     prodtable.initFromInventTable(inventTable);       prodtable.ItemId            ...

RelationshipType in D365 FO

  RelationshipType in D365 FO In  AOT > Data Dictionary > Tables > Table > Relations, you can set the value of the RelationshipTypeproperty of the new relation. The following table describes the elements of the RelationshipType property. Element name Description Automatic inference NotSpecified Often the default value for the  RelationshipType property. When the  RelationshipType  property has the value NotSpecified , the system infers an appropriate value. The system infers the value in the following sequence: 1.                Specialization 2.               Link 3.               Composition 4.             ...

Cardinality and RelatedTableCardinality table relation property in D365 FO

  Cardinality and RelatedTableCardinality table relation property in D365 FO Cardinality is the property which explains about nature of the relationship between two tables on the related table. For example: ZeroOne: You will select this, provided child Table/related table can either have no record or have only one related record (Fetch Mode is 1:1). ExactlyOne: You will select this, provided child Table/related table can have only one related record (Fetch Mode is 1:1).  ZeroMore: You will select this, provided child Table/related table can either have no record or more than one related record (Fetch Mode is 1:n). OneMore: You will select this, provided child Table/related table can have more than one related record (Fetch Mode is 1:n). Cardinality specifies how many instances of SalesLine row can be related to a single instance of SalesTable row. ZeroMore means that for every sale order, there can be zero, or more sales lines related to it. If the business require...