RSS

Monthly Archives: January 2012

Research method on X++ forms

In AX2009 if you call the research() method on a form passing true, the cursor position within a grid should be retained. However, this is true only if the query created by the form uses inner joins. Any outer joins, aggregations, temp tables, etc. cause the cursor to go to either the first or last record (depending upon the StartPosition property for that data source). In 2009 if you want to keep the cursor position and use joins other than inner joins you have to keep track of the cursor position. Code like the following will do this:
int pos;

super();

pos = SalesTable_ds.getPosition();
SalesTable_ds.research();
SalesTable_ds.setPosition(pos);

 

 
Leave a comment

Posted by on January 6, 2012 in X++

 

How to Identify the Tier X++ Code is Running On

It can be unclear as to which tier, either the client or the server, X++ code is executed on. This ambiguity can lead to problems. For instance if you run a server-bound batch, all of the code has to run on the server. If a call is attempted on the client this error will be thrown: “The server-side impersonated (RunAs) session tried to invoke a method that is available for client-side processing only.”
You can add statements to your class that will tell you which tier your code is executing on. Add the following to your X++ code:

info(strfmt(“%1”, xGlobal::clientKind()));

The output of this line will be either Client or Server

 
Leave a comment

Posted by on January 6, 2012 in Microsoft Dynamics AX, X++

 

Tags: