Personalized Community is here!
Quickly customize your community to find the content you seek.
Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 Release Wave 2Discover the latest updates and new features to Dynamics 365 planned through March 2021.
Release overview guides and videos Release Plan | Preview 2020 Release Wave 2 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I'm looking to import an excel file through x++ code, to Movement Journal.
What I want is - when I run the project, there should be a dialog box with a button to upload the excel file and on pressing OK, the file should be uploaded and the values should be set in the Movement Journal Lines.
The Problem is that I don't know what kind of project should I create to do this.
should I create an RDP class and use it with UI Builder class and Contract class or it is done in the forms?
What is the exact solution?
Are you aware of the Data Import Export Framework? This can already import Excel files. There is an entity available for an inventory journal: docs.microsoft.com/.../data-import-export-framework-entities-dixf-dmf
This would save you from some development efforts.
There are some posts related to this.
Please check e.g. the following sites:
Have you tried following the code examples provided and did you make some progress?
Please let us know if there is anything else the community can help you with.
Many thanks and best regards,
Hi Ludwig Reinhard
I really really appreciate your help!
I have created a job to import the excel file and there is one little problem.
which is - When I post the excel file, it says posted and Movement journal is created but when I check the movement journal in the form, the lines are not created
Can you tell me the issue by seeing my code ?
Here it is-
static void InsertRecords(Args _args)
int row =1;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
dialog = new Dialog("FileOpen");
dialogfield = dialog.addField(extendedTypeStr(Filenameopen), "File Name");
filename = (dialogfield.value());
throw error("File cannot be opened.");
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
//Incrementing the row line to next Row
if(i == 1)
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
// Init JournalTable
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = InventJournalType::Movement;
journalTable.JournalNameId = journalTableData.journalStatic().standardJournalNameId(journalTable.JournalType);
journalTrans.TransDate = systemDateGet();//mkDate(15,11,2013);
journalTrans.ItemId = cells.item(row,2).value().bStr();
inventDim.InventSiteId = inventLocation.InventSiteId;//
inventDim.InventLocationId = cells.item(row,4).value().bStr();//Ware House
select firstFast inventLocation where inventLocation.InventLocationId == inventDim.InventLocationId;
inventDim.wMSLocationId = cells.item(row,5).value().bStr();//A-01-00
journalTrans.Qty = Cells.item(Row,6).value().double();//.float();//.double(); //date();
journalTrans.CostPrice = decRound(cells.item(row,7).value().double(),2);
journalTrans.CostAmount = journalTrans.Qty * journalTrans.CostPrice;
// journalTrans.LedgerDimension = cells.item(row,9).value().toString();//.bStr();//double();//.bStr();
// inventDim.configId =cells.item(row,15).value().bStr();//here (EcoResConfiguration)=color
// inventDim.inventBatchId = cells.item(row,7).value().bStr();
//inventDim.inventSerialId = cells.item(row,16).value().bStr();
//inventDim.InventLocationId = cells.item(row,14).value().bStr();*/
//for offset account
// journalTrans.LedgerDimension = cells.item(row,14).value().toString();//.bStr();//double();//.bStr();
// journalTrans.InventDimId = _inventDim.inventDimId;//"FCC-000153";
journalTrans.InventDimId = _inventDim.inventDimId;//"FCC-000153";
// Loads the next row into the variant type and validating that its is empty or not
type = cells.item(row+1, 1).value().variantType();
while (type != COMVariantType::VT_EMPTY);
// quits the application
info(strFmt("Inventory Journal Imported :%1",journalTable.JournalId));
How does your file look like?
Are the items in your file matching those in your system?
This is my file and yes the fields match
It is a bit hard to read the coding with some obsolete lines (out commented).
I would suggest to use the debugger to see what exact values are read from the Excel file and if the journal ID is set correctly when you insert the lines.
As mentioned above, you can also use the Data Import Export Framework without coding; just configuration.
Thanks again for the help
I'm now using the code in this blog post. Here is the link-
But when I post the excel file, it is showing an error, "item number must be specified"
Can you tell me the reason of this issue?
this error is coming when you called the journalTrans.insert(); due to the item code field is mandatory in the journal lines table
this may be due to the item id cell in excel is not in the text format in this case it will be imported as a blank value
Have you tried sending the author of the post a direct message asking for a demo sample import file and the error message that you see?
The coding in the blog is assuming that the contents of the Excel column for the item number is a string (bStr()). Can you check the contents? If it is a number only, you have to use another command to read the Excel cell or change the format in Excel.
I've checked and the item number format in the Excel sheet is Text and in code its string so It should work for me but it isn't. I'm using item numbers like F0001,D0001 etc.
Can anyone help me?
You have to check the value of the COMVariantType using a debugger or info statement.
When it is VT_BSTR then the command bStr() should be used. If it is VT_I1, you can use the method char() to get the value.
Have you checked using the debugger if a value has been retrieved or what exactly is causing the error?
Business Applications communities