Dynamics Ax creating a batch job from code

Hi, Here is a simple code snippet to create Batch jobs from code. This convenient when starting a heavy load job from a user interface and still keep the client responsive. TSTSalesOrderUpdate tSTSalesOrderUpdate;   BatchInfo batchInfo; BatchHeader batchHeader; ;   tSTSalesOrderUpdate = TSTSalesOrderUpdate::construct();   batchInfo = tSTSalesOrderUpdate.batchInfo(); batchInfo.parmCaption("Test from code"); batchInfo.parmGroupId("");   batchHeader = BatchHeader::construct();… Continue reading Dynamics Ax creating a batch job from code

Dynamics Ax Creating sales orders with the SalesAutoCreate class

Many projects use an interface to import their sales orders, because of this a SalesAutoCreate class was created. This class is easily extendable and customizable.The first thing to do is designing a buffer table, like this one for example: After this we can start extending a new class from the SalesAutoCreate class and modifying the… Continue reading Dynamics Ax Creating sales orders with the SalesAutoCreate class

Dynamics Ax Cleaning up the AIF document log

While doing a small AIF project I wrote a small batch class to cleanup the AIF document log because the button on the AifDocumentHistory form can take up a huge amount of time. The first thing I did to write this class is checking out the standard Ax code in the following method ClassesAifMessageManagerclearAllProcessedAndError. This… Continue reading Dynamics Ax Cleaning up the AIF document log

Dynamics Ax 2009 using the DateTimeUtil

Since i’m getting a lot of google hits on my Dynamics Ax – workdays to days post, i’ve decided to blog some more about it. The DateTimeUtil class is actually a wrapper of the .NET DateTime class. A first thing to remember when using UtcDateTime EDT’s is that it is stored like the name says… Continue reading Dynamics Ax 2009 using the DateTimeUtil

Dynamics Ax modifying CreatedDateTime

For testing purposes with the MRP we needed to modify the createdDateTime fields in Dynamics Ax 2009. Since these are system fields we needed a workaround. if(isRunningOnServer() && CurUserId() == "Admin") { new OverwriteSystemfieldsPermission().assert();   salesLine.overwriteSystemfields(true); // "YYYY/MM/DD HH:MM:SS" salesLine.(fieldnum(SalesTable,CreatedDateTime)) = str2datetime( "2010/04/03 11:00:00" ,321 ); salesLine.doInsert(); salesLine.overwriteSystemfields(false);   CodeAccessPermission::revertAssert(); } Remarks: Make sure that… Continue reading Dynamics Ax modifying CreatedDateTime

Dynamics ax a key with the name %1 already exists

Today I had to fix a bug in some custom code in Dynamics Ax 2009, we had an error from the JournalTransList class that stated “A key with the name %1 already exists.” Cause: A custom field on the WMSJournalTrans table that was extending from LineNum Reason: The JournalTransList has methods to check if the primary… Continue reading Dynamics ax a key with the name %1 already exists

Dynamics Ax workdays to days

Ever had to calculate the number of days starting from a number of workdays and even deal with holidays. A pretty straightforward example using the DateTimeUtil class and DayOfWk method. static void WorkDaysToDays(Args _args) { int workDays = 10; int days = 0; date startDate = systemDateGet(); CalendarId calendarId = CompanyInfo::find().ShippingCalendarId; ;   if(calendarId) {… Continue reading Dynamics Ax workdays to days