How to check if a table has records in it, from its name, NOT from a buffer.
The trick is some standard AX dict classes reflection (specifically DictTable):
static void recordsExist(Args _args)
{
  SysDictTable dictTable;
  ;
  dictTable = new SysDictTable(tableName2Id('TableStringHere'));
  if (dictTable)
  {
    if (dictTable.recordCount() > 0)
      info ("This table has records.");
    else
      info ("No records");
  }
  else
    info ("Table does not exist");
}
If you any questions or comments e-mail me on: mirko@mirkobonello.com