Friday, February 17, 2023

Loop all tables and get details table hasNaturalKey or not in D365FO X++

 public static boolean hasNaturalKey(TableId _tableId)

    {

        SysDictTable    dictTable;

        DictIndex       dictIndex;

        boolean         hasNaturalKey;

        TableId         currentTableId;



        currentTableId = _tableId;

        do

        {

            dictTable = new SysDictTable(currentTableId);

            dictIndex = dictTable.indexObject(dictTable.replacementKey());

            hasNaturalKey = (dictIndex != null) && (dictIndex.numberOfFields() > 0);


            currentTableId = dictTable.supportInheritance() ? dictTable.extends() : 0;

        }

        while (!hasNaturalKey && currentTableId != 0);


        return hasNaturalKey;

    }

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...