A blog offering various X++ code snippets and tips for Microsoft Dynamics AX

Tuesday, October 28, 2008

Using an AOT query in a form at runtime

This is not the recommended/standard way to use queries in forms but in case you might need it - here is how it can be done:


public void init()
{
  QueryRun queryRun;
  Args args = new Args();
  ;
  super();

  args.name(querystr(MyAOTQuery));
  queryRun = classfactory.queryRunClass(args);
  this.query(queryRun.query());
}


In the above snippet, inserted in the init() method of the datasource, a QueryRun and an Args object was created. The args.name property was set to the AOT query you want to use in your form and the queryRun was constructed using this args object. Finally the query of the datasource (remember that 'this', in the code snippet, is the current datasource) is set to the query of the QueryRun.

If you any questions or comments e-mail me on: mirko@mirkobonello.com

No comments: