Wednesday, October 12, 2011

What about 'The command-line parameter -compressionminsize=1024 is invalid.' error message?

When starting the Ax client by clicking an Ax configuration file (.AXC), you may receive following error message:

The command-line parameter -compressionminsize=1024 is invalid.
Check the spelling and start Microsoft Dynamics AX again.




Possible cause, and a solution:
You are using an Ax configuration file to start Ax.  But instead of using a configuration file created for an Ax client, you are using a configuration file of the Dynamics Ax AOS server.
Make sure to use the Ax client configuration utility to create the AXC file, not the server configuration utility.

Monday, October 10, 2011

What not to forget when using the changecompany keyword

When debugging some Ax code the other day, I stumbled upon some good looking but not working code.  What at first sight looked OK, missed a small but vital detail.

The code involved the use of the changecompany keyword.  It's an easy approach for reading records from different company accounts within one Ax database.
The syntax is pretty straightforward:

   changecompany('id')
   {
       // record handling
   }

Put the record handling between accolades and you are good to go.  But...


Example of some disfunctional code:

static void MyExample(Args _args)
{
   DataArea DataArea;
   CustTable CustTable;
   ;

   while select DataArea
      where !DataArea.isVirtual
   {
      changecompany(DataArea.id)
      {
         while select CustTable
            where CustTable.Name like 'A*'
         {
            info(strfmt("%1 %2 %3",CustTable.dataAreaId,CustTable.AccountNum,CustTable.Name));
         }
      }
   }
} 

The above does not work or gives unreliable results.
What to do: You have to reset your table variable, after the changecompany but before your perform the record handling..
Example of some working code:

static void MyExample(Args _args)
{
   DataArea DataArea;
   CustTable CustTable;
   ;

   while select DataArea
      where !DataArea.isVirtual
   {
      changecompany(DataArea.id)
      {
         CustTable=null;          // remember to reset the record object
         while select CustTable
            where CustTable.Name like 'A*'
         {
            info(strfmt("%1 %2 %3",CustTable.dataAreaId,CustTable.AccountNum,CustTable.Name));
         }
      }
   }
}