Thursday, August 5, 2010

Calling method at runtime

In Dynamics AX, you can decide at runtime whether you need to call a method or not. See example below in which the find method of CustTable is called at runtime.

static void invokeMethodOnRunTime(Args _args)
{
   DictTable dictTable = new DictTable(tablenum(CustTable));
   CustTable custTable;
   //Check if class/table has method

   if(tableHasStaticMethod(dictTable, identifierstr('find')))
  {
       custTable = dictTable.callStatic(tableStaticMethodStr(CustTable, Find), '4000');
       info(custTable.name());
  }

}

Monday, August 2, 2010

Getting number of rows loaded

To get the number of rows loaded to the Dynamics AX datasource, you can use the following function of the datasource.

[datasource].numberOfRowsLoaded();

For example:

custTable_ds.numberOfRowsLoaded();