Thursday, May 29, 2008

Wednesday, May 28, 2008

Using the AutoRun parameter to open a form in AX

In AX 4.0 and later you can use a start up parameter called AutoRun and combined with an XML file you can automate a lot of stuff in AX after starting the client.

The command line for AutoRun looks like this:
ax32.exe –StartupCmd=AutoRun_ c:\folder\filename.XML

The XML file holds descriptions of the commands to execute when the client is started.

The following is an example on how you can use this to open the CustTable form immediately after login.

First create the XML fle:

The exitWhenDone tag controls if AX should shut down after completing the tasks listed in the XML file. We don't want that in this case.

I'm saving the file as C:\OpenCustTable.XML.

And then you could create a specfic configuration file to use this start up parameter:

You could of course also just point to this at the command prompt.

That's it...

You can add as many commands as you want to the XML file, so you can really automate a lot of stuff.

The supported commands includes, amongst others:

  • Runnning installation, upgrade or configuration check lists
  • Loading license information
  • Compiling the application
  • Syncronize the database
  • Importing data
  • Importing XPO's
  • Running specific elements (like described on the above example)

Search the Administrator Help for "SysAutoRun" to read the included documentation.

Tuesday, May 27, 2008

Change the appearance of printed report ranges

In AX you can order selected reports asking the system to print the ranges of your query.

To try this, go to Accounts Receivable / Reports / Base data / Customer.

  • Click Select
  • Click Print Options
  • Check the “Print ranges” check box.

The report header ends up looking something like this example:

Technically this is a fine solution, but it’s not very sexy. So how do you go about changing this section? Take a look at the method \Classes\SysReportRun\buildPrintRanges. This is where AX on the fly builds a new report section with the needed fields and it executes the section to print the requested information.

For a regular no-nonse report like the Customer report, this feature is called from the report template behind the report: \Reports\Report Templates\InternalList\PageHeader:PgHdr_1\Methods\executeSection:

public void executeSection()
If you switch the two lines in this method, you will get the ranges printed under the regular page header, which I think is a bit nicer:

You can add the same lines to your own reports that may not use this template, as long as it is called from the page header section.

With a few lines of additional code in \Classes\SysReportRun\buildPrintRanges you can create cool effects (well, semi-cool):

This will produce a result like this (assuming you have also changed the order of the lines in \Reports\Report Templates\InternalList\PageHeader:PgHdr_1\Methods\executeSection as described above):

Transform a date into a number of months from a specific offset date

Here is a small algorithm to transform a date into a number of months from a base date. You can for example use this if you need to create a report with numbers places in a column per month starting with the month of a specific date.

The algorithm to transform the date into a month is this:
if (columDate < dateEndYr(offSetDate))
column = mthOfYr(columDate) - mthOfYr(offSetDate) + 1;
column = 12 - mthOfYr(offSetDate) + mthOfYr(columDate) +1;

And here is a job to illustrate the usage:

static void date2Column(Args _args)
Date offsetdate;
Date columDate;
int column;
int counter;

offSetDate = 30\09\2008;
columDate = offSetDate;
while (counter <= 11)
// The actual algorithm -->
if (columDate < dateEndYr(offSetDate))
column = mthOfYr(columDate) - mthOfYr(offSetDate) + 1;
column = 12 - mthOfYr(offSetDate) + mthOfYr(columDate) +1;
// The actual algorithm <--
print strFmt("Date: %1 Month: %2", columDate, column);
columDate = dateMthFwd(columDate, 1);

UPDATE: As you can see from the comments to this post, I could have simply used the following built in function:
intvNo(columDate, offsetDate, IntvScale::YearMonth) + 1

Friday, May 23, 2008

AX 2009 RTM

AX 2009 RTM is now available on PartnerSource (requires PartnerSource account).

The download is located here.

Tuesday, May 13, 2008

Data Migration Tool - Microsoft XAL to Microsoft Dynamics AX

Since support for XAL soon ends, hopefully many XAL customers will make the switch to AX.

To ease the switch, MS has updated their data migration tool to now support AX 4.0.

The tool can be downloaded from PartnerSource (requires PartnerSource login)

Tuesday, May 6, 2008

Dynamic date ranges in queries

When you send recurring jobs to the batch queue, there will be cases where you’d like some of your date criteria to be dynamic to match the system date.

You can use the “d” shortcut as criteria when you enter query selections and the system will convert “d” to the system date when the batch job is executed.

You can also use “d” in ranges:
..d = From date null (1/1/1900) until today
..d, !d = From date null (1/1/1900) until yesterday

I have tested these criteria on 4.0, I’m not sure you can do this with earlier versions. But please let me know if you can.

Changing the keyboard layout for the login of a VPC image

The VPC images we get form MS are always set up with US keyboard layout, so when you login to the the VPC image you have to know where the special characters in the password are located on a US keyboard layout.

Click here to get a solution on how you change the keyboard layout for the VPC image, so it also affects the login screen.

Thank you Joris, for this great tip.