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

Disabling the flight in D365FO (CHD - Tier 1)

 INSERT INTO dbo.SYSFLIGHTING(FLIGHTNAME, ENABLED)  VALUES ('<FlightObjectName>_KillSwitch', 1)  or  INSERT INTO dbo.SYSFLIGHT...