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

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...