Search This Blog

Saturday, October 22, 2011

Find mandatory fields in the table

This job is used to find the mandatory fields in the table.

static void Krishh_findMandatory(Args _args)
{
    TableId   tableId = tableNum(SalesTable);
    DictTable dt;
    int       fieldCnt;
    int       i;
    DictField df;
    ;
    dt = new DictTable(tableId);
    fieldCnt = dt.fieldCnt();
    for(i = 1; i <= fieldCnt; i++)
    {
        df = new DictField(tableId, dt.fieldCnt2Id(i));
        if(df.mandatory())
        {
            info("Field '" + df.name() + "' is mandatory.");
        }
    }
}

1 comment:

  1. Good One krish, how to extend this to get all the table (iterate through all the tables) in AX.

    Thanks
    Hari

    ReplyDelete

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.