Skip to main content

Posts

Showing posts from December, 2011

Import sales orders from master and details text files

The are many code snippets which you can find easily over the internet to import sales orders from a text file or from excel. The purpose of this post is to share my experience of uploading data into sales order form from two different text files. void ImportSalesOrders() {     Container                  con;     CustTable                 custTable;     SalesTable                salesTable;     SalesLine                  salesLine;     Headers                    headers;     Stock                        details;     num                           newSalesI...

Dynamics AX and database synchronization error

Due to huge customization in application we may come across database and application synchronization failure issue. Sometimes you will see this error when you add some new fields in CustTable or SalesTable, this is just for an example you can have this issue in any table or view. Following job will forcefully synchronize all the tables in AOT. static void forceDbSynchronize(Args _args) {     Dictionary                             dict;     int                                        idx, lastIdx, totalTables;     TableId                                  tableId;     Application                            app...

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

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