Posts

Showing posts from June, 2021

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;       Dialog dialog=new Dialog("Excel Import using dialog");       dialogUploadGroup=dialog.addGroup("@SYS54759");       formBuildControl=dialog.formBuildDesign().control(dialogUploadGroup.name());    

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                 = inventTable.ItemId;     prodtable.DlvDate                = today();     prodtable.QtySched               = qty;     prodtable.RemainInventPhysical   = qty;       inventDim.initValue();       // Set the active BOM and Route     prodtable.BOMId = BOMVersion::findActive(prodtable.ItemId,                                              prodtable.BOMDate,                                              prodtable.QtySched,                          

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.               Aggregation 5.               Association For example, if the criteria for both  Composition  and Aggregation  are met, the system infers  Composition . This is true because  Composition  occurs earlier in the list. Specialization Applies only to tabl

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 requirement dict

X++ Create Purchase order from Sales order in D365 FO

  X++ Create Purchase order from Sales order in D365 FO TmpPurchLinePrice tmpPurchLinePrice; PurchCreateFromSalesOrder PurchCreateFromSalesOrder; SalesTable salesTable; ; salesTable = salesTable::find(“SO0000009”); tmpPurchLinePrice.clear(); tmpPurchLinePrice.initValue(); tmpPurchLinePrice.Included = NoYes::Yes; tmpPurchLinePrice.LineAmount = 100; tmpPurchLinePrice.PurchUnit = “EA”; tmpPurchLinePrice.PriceUnit = 12; tmpPurchLinePrice.CurrencyCode = “USD”; tmpPurchLinePrice.ItemId = “0001882”; tmpPurchLinePrice.PurchQty = 2; tmpPurchLinePrice.AccountNum = “V000002“; tmpPurchLinePrice.SalesId = “SO0000009”; tmpPurchLinePrice.SalesLineRefRecId = 5637146077; tmpPurchLinePrice.LineNum = 2;   if (tmpPurchLinePrice.validateWrite()) { tmpPurchLinePrice.insert(); }   // Now create the Purchase Order purchCreateFromSalesOrder = PurchCreateFromSalesOrder::construct(); purchCreateFromSalesOrder.parmCallerRecord(salesTable); purchCreateFromSales

X++ code to create Direct Delivery Purchase order in D365FO

  X++ code to create Direct Delivery Purchase order in D365FO class DirectDeliveryPO { /// <summary> /// Runs the class with the specified arguments. /// </summary> /// <param name = “_args”>The specified arguments.</param> public static void main(Args _args) { PurchAutoCreate purchAutoCreate; PurchCreateFromSalesOrder purchCreateFromSalesOrder; TmpPurchLinePrice tmpPurchLinePrice; SalesTable salesTable; SalesLine salesLine; InventTable inventTable; VendAccount prevVendAccount; LineNum lineNum = 0; SalesId salesId = ‘SO000081’; str curCompany = curExt();   try { ttsbegin;   while select salesLine order by inventTable.PrimaryVendorId where salesLine.SalesId == salesId join inventTable where inventTable.ItemId == salesLine.ItemId { if (prevVendAccount && prevVendAccount != inventTable.PrimaryVendorId) { purchAutoCreate = PurchAutoCreate::construct(tmpPurchLinePrice, purchCreateFromSalesOrder);

Data Migration tool : AX 2009 to D365

Data Migration tool : AX 2009 to D365FO   While click on generate mapping in data migration tool in AX 2009  getting the error "The given value of type string from datasource cannot be converted to type nvarchar of specific target column". The issue of String error should be gone after increasing the length of DMTName EDT.

X++ code to get ledgerDimension for MainAccount

Image
  X++ code to get ledgerDimension for MainAccount

X++ Code to enable or disable dialogfield in UIBuilder class in D365FO

  X++ Code to enable or disable dialogfield in UIBuilder class in D365FO   class disableFieldUIBuilder extends SysOperationAutomaticUIBuilder {       private disableFieldContract testContract;       private DialogField dialogCode;       /// <summary>     ///       /// </summary>       public void postBuild()     {           testContract;= this.dataContractObject();           super();         dialogCode = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(disableFieldContract , parmCode));           dialogCode.enabled(false);       }   }

X++ code to check Fiscal calendar period in D365FO

  X++ code to check Fiscal calendar period in D365FO public static boolean findFiscalCalendarPeriod(TransDate _date) {         RecId calendarRecId;         FiscalCalendarPeriod fiscalCalendarPeriod;         calendarRecId = Ledger::fiscalCalendar(CompanyInfo::find().RecId);         fiscalCalendarPeriod = FiscalCalendarPeriod::findPeriodByCalendarDate(calendarRecId, _date, FiscalPeriodType::Operating);            if (_date)          {               if (!fiscalCalendarPeriod)             {                 return checkFailed(strFmt("@SYS17614",date2StrUsr(_date,DateFlags::FormatAll)));             }               if (fiscalCalendarPeriod.currentLedgerPeriodStatus() != FiscalPeriodStatus::Open)             {                 return checkFailed(strFmt("@SYS17615", date2StrUsr(_date,DateFlags::FormatAll)));               }            }         return true;       }