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;   ...

Create and Post Inventory Movement Journal in AX / D365 FO via X++

Create and Post Inventory Movement Journal in AX / D365 FO via X++


InventJournalTable              inventJournalTable;
InventJournalTrans              inventJournalTrans;
InventJournalNameId          inventJournalName;
InventDim                               inventDim;
JournalCheckPost                  journalCheckPost;

//<Creation of journal header>  
    
inventJournalTable.clear(); 
//Type Movement is Movement Journal
inventJournalName =  InventJournalName::standardJournalName(InventJournalType::Movement); 
inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalName)); 
inventJournalTable.insert();

 //<End Creation of journal header>

//<Creation of journal Line>

inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable); 
inventJournalTrans.TransDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
inventJournalTrans.ItemId = "ItemID"; //change here item number
inventJournalTrans.initFromInventTable(InventTable::find("ItemID"));
inventJournalTrans.Qty = 1;//qunatity
inventDim.InventSiteId  = “SiteId”;
//you can add here as many inventory dimensions as required
inventJournalTrans.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;
inventJournalTrans.insert();

//<End Creation of journal Line>
       
//<Post Journal>
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable); 
journalCheckPost.parmThrowCheckFailed(false);
journalCheckPost.parmTransferErrors(NoYes::No);
journalCheckPost.run();
//<End post Journal>
   
info(“Journal Created and Posted”);

Comments

Popular posts from this blog

D365 FO: REFRESH CALLER FORM DATA SOURCE FROM A CLASS X++

Passing Args from one Form to another Form in dynamics AX

CREATE AND POSTING PURCHASE ORDER THROUGH X++ DYNAMICS AX