Posts

Showing posts from 2011

Trimmed print preview and print

A user prints a document in AX; unlike the normal (A4) print the preview displays a trimmed page when the user has done nothing with the print settings. This phenomenon was discovered when a customer had a label printer connected with usb to here computer and used citrix to logon to a computer with AX on. When the user logged on to the citrix computer with its local printer this printer was set as default printer. When AX creates the preview of the printed document it will ask the default printer for the print page dimensions. Since the label printer only can print a specific dimension AX will use the default printer dimensions for the print preview. A quick fix is to not bring the local printer along when login on to the citrix environment.

Code example of how to use the List datastructure

The list is a usefull datastructure that can contain any type of x++ types. Here are some code examples of how it can be used. First Example List list = new List(Types::Integer); Enumerator en ; list.addEnd(333333); // add the value at last list.addEnd(111111); list.addEnd(222222); en = list.getEnumerator(); print list.elements(); //"print number of element" while (en.moveNext()) { print en.current(); } pause; Second Example List list1 = new List(Types::Integer); List list2 = new List(Types::Integer); List combinedList = new List(Types::Integer); int i; ; for(i=1; i<6; i++) { List1.addEnd(i); } for(i=6; i<11; i++) { List2.addEnd(i); } combinedList = List::merge(list1, list2); print combinedList.toString(); pause; Copied from here

Dynamics AX 2009 batch engine, how it works under the hood

Here is a good description of AX 2009 batch engine and how it work under the hood. Good to know also. The batch engine will unpack the job and execute the run() method. 

Working with dates in x++

These are some good methods for working with the dates. today(); //Returns the current date date2Str(currentDate, 321, // sequence of date parts 3=year 2=month 1=day DateDay::Digits2, DateSeparator::Hyphen, // separator1 DateMonth::Digits2, DateSeparator::Hyphen, // separator2 DateYear::Digits4 ); str2Date("2011-06-30",321) // turns the string into a date mthofyr(today()) //returns the current month as a integer. year(today()) //returns the current year as a integer. dayofmth(today()) //returns the dat as a integer. If you are working UTCDates that was introduces in AX 2009 there is a class called DateTimeUtil that contains all the functions that is needed. For utcdates use datetimeutil::utcNow() instead of today() Records that are displayed in ax without a date are stored in the database as 1900-01-01.

Tracing a infolog message

If you put a breakpoint in the method \Classes\Info\add on line 14 "AppPlatformEvent::Info_add(_exception, _txt, _helpUrl, _sysInfoAction, buildPrefix);" and run your code, the debugger will break where the infolog is displyaed. Very useful when you get an unexpected error message.

Box with Yes/No alternativ

A simple way to query a user for a decision. if(box::yesNo("Do you want to do this?",dialogbutton::Yes) == dialogbutton::Yes) { //run som code here }

Error during data migration while upgrading to AX 2009

When you're upgrading your existing AX 3.0 SP6 environment to AX 2009 you may run into following error: Object Server 01: The database reported (session 5 (Admin)): [Microsoft][SQL Native Client][SQL Server]The specified schema name "DOMAIN\COMPUTERNAME$" either does not exist or you do not have permission to use it.. The SQL statement was: "CREATE FUNCTION [DOMAIN\COMPUTERNAME$].FN_FMT_NUMBERSEQUENCE This is caused by getSchemaName() method in ReleaseUpdateDB class. This method executes SELECT current_user SQL statement to retrieve name of user connected to SQL Server. This returns name of the account running AOS service. This name is then used as name of schema in which the database object is being created. To create the object always in DBO schema you need to modify the getSchemaName() method to call xSession::getDbSchema() method that always returns DBO for SQL Server database. The method will look like follows: protected static str getSchemaName(Connection _con

Development licenses AX 2009

Information about the license keys needed for developing in a ax environment. Base Application: This will allow to have access to UI elements like Menus, Forms. MorphX Development Suite: With this licence you will be able to see the Data Dictionary and other UI objects (reports etc). Web MorphX Development Suite: Controls access to web development objects in AOT. X++ Source Code: This licence allows to have access to Class objects in AOT.