Skip to main content

Posts

Showing posts from January, 2010

AX - SQL query another database via ODBC

Recently I was involved in migrating a large data set from another database. The standard Excel import/export is a great tool for migrating data. Once you start importing over 500 records - it can get very slow. Here is some code to do an ODBC connection to execute a select statement. server static void main(Args args) { LoginProperty loginProperty; ODBCConnection connection; Statement statement; ResultSet resultSet; SqlSystem sqlSystem; SqlStatementExecutePermission sqlStatementExecutePermission; str sql = 'SELECT * FROM Vendor'; ; sqlSystem = new sqlSystem(); loginProperty = sqlSystem.createLoginProperty(); // Set server - if you dont setServer. It will use current server the AOS is on. loginProperty.setServer('localhost'); loginProperty.setDatabase('OtherDb'); connection =

AX - Loop through dimensions

This is a good article regarding handling dimensions in code. http://blogs.msdn.com/palle_agermark/archive/2006/03/30/Additioanl-Financial-Dimensions.aspx General idea to loop through dimensions. static void PrintDimensions(Args _args) { Dimension dimension; int numOfDimensions, i; ; numOfDimensions = dimOf(dimension); for (i = 1; i <= numOfDimensions; i++) { info(myTable::find('1001').dimension[i]); } }

NAV - Change language at runtime

In my last post . I showed how you can change the system language at runtime. You might want to do this when a you want to print 1 single report in a different language. NAV has the same ability too. GLOBALLANGUAGE := 3081; // To set it to Australia To find the language ID. Go to Tools -> Language. Then use Zoom (Ctrl+F8) on this form. Warning: Set the language back when the report is finished.

AX - Change language at runtime

Last week I got a request to write a report in a different language. Instead of creating new labels. You can change the language at runtime using the infolog.language() method. static void TestDiffLanguage(Args _args) { ; info("@SYS22548"); infolog.language('de'); info("@SYS22548"); infolog.language('En-US'); info("@SYS22548"); infolog.language('ar'); info("@SYS22548"); infolog.language('En-AU'); } I used it in the header and footer methods of the report. Warning: This will change you system language. Make sure you set back to your own language at the end.