Saturday 21 February 2015

Finding the mandatory fields on table by using X++ code.


The below code is used to get the mandatory fields on table using X++.


static void CheckMandatoryFieldsOnTable(Args _args)
{
    DictTable   dictTable;
    DictField    dictField;
    int               i;
   //Pass the table name
    TableId       tableId = tablenum(SalesTable);
    ;

    dictTable = new DictTable(tableId);
    for (i=1 ; i<=dictTable.fieldCnt() ; i++)
    {
        dictField = new DictField(tableId, dictTable.fieldCnt2Id(i));

        if (dictField.mandatory())
        {
            info(dictField.name());
        }

    }
}


output :


No comments:

Post a Comment