Blog

Name is Anant Dubey and the intent to create this blog is to discuss the problems and issues that developer face in the dynamics AX development and to share the new things that come up with the new version of AX.

Monday, January 13, 2025

Import data through CSV in AX2012

static void ADUpdateInventTable(Args _args) { CommaTextIO csvFile; container readCon; Dialog dialog; DialogField dfFileName; FileName fileName; InventTable inventTable; ItemId itemId; //DirPartyContactInfoView contactView; #File dialog = new Dialog("Pick the file"); dfFileName = dialog.addField(extendedTypeStr("FilenameOpen")); dialog.filenameLookupFilter(['csv','*.csv']); if (dialog.run()) { csvFile = new CommaTextIo(dfFileName.value(), 'r'); csvFile.inFieldDelimiter(','); readCon = csvFile.read(); while(csvFile.status() == IO_Status::OK) { readCon = csvFile.read(); if(readCon) { itemId = conPeek(readCon,1); ttsBegin; select forUpdate inventTable where inventTable.ItemId == itemId; if(inventTable.Test == NoYes::Yes) { inventTable.Test = NoYes::No; inventTable.update(); } ttsCommit; info(itemId); } } } }

No comments:

Post a Comment