How to find the mandatory fields in the table manually in Dynamics Ax


Description:-

You see the wavy red line when a Field is set as Mandatory on the Form/Table. This is a good way of making it clear to the user which fields are always required.
Here is the Job to Find mandatory Field from the table.

USING SYSDICTTABLE CLASS

static void mandatoryFieldsOfATable(Args _args)
{
  SysDictTable sysDictTable;
  SysDictField sysDictField;
  TableId tableId;
  Counter counter;
  ;
  sysDictTable = new SysDictTable(tablenum(SalesTable));
  for(counter = 1;counter <= sysDictTable.fieldCnt(); counter++)
  {
    sysDictField = new sysDictField(sysDictTable.id(), sysDictTable.fieldCnt2Id(counter));
    if(sysDictField.mandatory())
    info(sysDictField.name());
  }
}

Output:-

Related Posts

Previous
Next Post »

Thanks for comments.....