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

Run custom X++ scripts with zero downtime

  Run custom X++ scripts with zero downtime In 10.0.25 you can run simple X++ scripts on a production environment without any down time.   This feature lets you upload and run deployable packages that contain custom X++ scripts without having to go through Microsoft Dynamics Lifecycle Services (LCS) or suspend your system. Therefore, you can correct minor data inconsistencies without causing any disruptive downtime. The benefit of using an X++ script to correct minor data inconsistencies is that the system will automatically adjust all related tables as required when it runs the script. This approach helps ensure the integrity of the correction and helps minimize the risk of introducing new inconsistencies. Read more: https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/deployment/run-custom-scripts

D365 FO Cancel Deliver Remainder Quantity In Sales Order Lines X++

  D365 FO Cancel Deliver Remainder Quantity In Sales Order Lines X++ while select forupdate salesLine where salesLine.SalesId == ' Sales Id'   {                SalesUpdateRemain::updateDeliveryRemainder(salesLine, 0, 0); }     Or    For particular Sales order   SalesUpdateRemain::cancelRemainderOnOpenSalesLines(salesTable)  

D365 FO X++ and the dangers of converting enum to string

 D365 FO X++ and the dangers of converting enum to string When converting an enum to string in X++. If you are using enum2str() the result depends on the   preferred locale. PurchRFQType prt = PurchRFQType::Received; str result = enum2Str(prt); info(result);     If you are using enum2symbol the resulting string to be the name of the enum value   PurchRFQType prt = PurchRFQType::Received; str result = enum2Symbol(enumNum(PurchRFQType), prt); info(result);   // info   "Received" regardless of the locale  

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!’, salesId)); }   } c

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()));         }     }      }