Delete duplicate records from table
Sometimes we lost unique identity check in the tables while doing some customization in Dynamics AX. It may happen due to failure of database synchronization. Here is the code to remove the duplicate records from a table, I used Dimension table as an example; static void deleteduplicate(Args _args) { set fieldSet = new set(Types::Integer); // create dicindex from the unique index DictIndex dictIndex = new Dictindex(tablenum(Dimensions),indexnum(dimensions, DimensionIdx)); ; // these are the fields from the index // add them to a set fieldset.add(fieldnum(Dimensions, DimensionCode)); fieldset.add(fieldnum(Dimensions, Num)); // set allow duplicates ReleaseUpdateDB::indexAllowDup(dictIndex); // delete duplicate records ReleaseUpdateDB::deleteDuplicatesUsingIds(tablenum(Dimensions), 1, fieldset); // re-enable index ReleaseUpdateDB::indexAllowNoDup(dictIndex); info(‘Done’); }
Format the system date in Dynamics AX
The following code show the dates in format like December 22, 2011 static void datesJob(Args _args) { str dd, mm, yy, dt; dt = date2Str(systemDateGet(), 123, DateDay::Digits2, DateSeparator::Slash, DateMonth::Digits2, DateSeparator::Slash, DateYear::Digits4); dd = substr(dt, 0, 2); mm = substr(dt, 4, 2); yy = substr(dt, 7, 4); dt = mthname(str2int(mm)) + ‘ ‘ + dd + ‘, ‘ + yy; print dt; pause; }
Dynamics AX – Use definition groups to import data
It’s perfectly correct that we always learn when we want to or when we are in need of achieving goals. This happened to me for last couple of weeks when I was looking for different ways to import data in Dynamics AX 2009. I came to know that we can use data definition groups under Administration > Periodic > Data export/import > Definition groups to import data from excel or csv files. Here you can find the complete information to import data using data definition group. Any questions and comments will highly be appreciated!
How to get the filtered datasource query after pressing Ctrl +G
Question: How to get filtered query after using filter by grid option in grid Grid showing filter records Grid showing complete list of records Answer: You can get the query which is created after providing filter criteria like this; datasourceName.queryRun().query().datasourceNo(1).ToString();
Find On-Hand inventory
While working on inventory module I wrote this code to find out the On-Hand inventory by using the InventOnHand class. static void findingOnHand(Args _args) { ItemId itemId; InventDim inventDim, inventDimCriteria; InventDimParm inventDimParm; InventOnhand inventOnhand = new InventOnhand(); ; itemId = ‘00200956’; inventDimCriteria.InventLocationId = ’08’; inventDimParm.initFromInventDim(inventDimCriteria); inventOnhand.parmInventDim(inventDimCriteria); inventOnhand.parmInventDimParm(inventDimParm); }
Find On-Hand inventory on given date
This piece of code can help you to find out On-Hand inventory at a particular date. static void findingOnHandByDate(Args _args) { ItemId itemId; InventDim inventDimCriteria; InventDimParm inventDimParm; InventSumDateDim inventSumDateDim; ; // Specify the item to get onhand info on itemId = ‘00005’; //inventDimCriteria.InventColorId = ’02’; inventDimParm.initFromInventDim(inventDimCriteria); inventSumDateDim = InventSumDateDim::newParameters(mkdate(31,12,2009), itemId, inventDimCriteria, inventDimParm); info(strfmt(“PostedQty: %1”,inventSumDateDim.postedQty())); info(strfmt(“DeductedQty: %1”,inventSumDateDim.deductedQty())); info(strfmt(“ReceivedQty: %1”,inventSumDateDim.receivedQty())); }
Check Active Inventory Dimension
In recent time I came across with a requirement how to find out an active inventory dimension associated with an item. Here is a sample job to do this task; static void checkInventDimActive(Args _args) { ItemId itemid = “1000”; ; info(strfmt(“%1”, InventDimSetup::find(InventTable::find(itemid).dimGroupId, fieldNum(InventDim, configId)).Active)); }
Dynamics Ax 4.0 installation
This question is being from many folks. How to install the Dynamics AX on non-domain computers. This article is going to help you to resolve the issue.
Update record after record insert in table
If you are getting the following error while inserting and updating records. Cannot edit a record in Table (Tablename).An update conflict occurred due to another user process deleting the record or changing one or more fields in the record. You will be doing it in this way; 1.Table table; 2.; 3.table.Field1 = ‘A’; 4.table.insert(); 5. 6.table.Field2 = ‘Desc’; 7.table.update(); To avoid such cases: 01.Table table; 02.; 03.ttsbegin; 04.table.Field1 = ‘A’; 05.table.insert(); 06. 07.table.Field2 = ‘Desc’; 08.table.update(); 09.ttscommit; Or this way: 01.Table table; 02.; 03.table.Field1 = ‘A’; 04.table.insert(); 05. 06.// time consuming other code here 07. 08.ttsbegin; 09.table.selectForUpdate(true); 10.table.reread(); 11.table.Field2 = ‘Desc’; 12.table.update(); 13.ttscommit;
List of “Whats New in Dynamics AX 2012″ Documents is Now on PartnerSource!
Finally Microsoft has released some documents about the long waited Microsoft Dynamics AX 2012. These new training materials highlight the new features in Microsoft Dynamics AX 2012. These materials are currently downloadable on PartnerSource (Partner Service Plan required). They will be orderable (can be purchased) beginning April 21. What’s New – Application in Microsoft Dynamics AX 2012 for Finance, PA, Case Mgmt., HRM and Public Sector Course Number 80164 What’s New – Technical in Microsoft Dynamics AX 2012 for Implementation Course Number 80165 What’s New – Application in Microsoft Dynamics AX 2012 for Supply Chain Management and Manufacturing Course Number 80163 What’s New – Technical in Microsoft Dynamics AX 2012 for Development Course Number 80299 What’s New – Local Functionality in Microsoft Dynamics AX 2012