Problems with Var type FieldRef/KeyRef

I have a table 50000 Test_KeyCount defined as followsEnabled Field No. Field Name Data Type Length Yes 1 Field_1 Code 10 No 2 Field_2 Code 10 Yes 3 Field_3 Code 10with the following keysEnabled Key Yes Field_1 No Field_2 Yes Field_3If I run the next code I get the results on the commentsRecRef.OPEN(DATABASE::"Test_KeyCount"); IF CONFIRM('Fields: %1\Keys: %2', TRUE, RecRef.FIELDCOUNT, RecRef.KEYCOUNT) THEN; // >>> Result: Fields: 2 // Keys: 2 // // Seems to get only "Active Fields/Keys" FOR i := 1 TO RecRef.FIELDCOUNT DO IF CONFIRM('i=%1 - FiedlIndex_%1: %2', FALSE, i,RecRef.FIELDINDEX(i).NAME) THEN; // >>> Result: i=1 - FieldIndex_1: Field_1 // i=2 - FieldIndex_2: Field_3 // // Like before, seems to get only "Active Fields" FOR i := 1 TO RecRef.KEYCOUNT DO IF CONFIRM('i=%1 - KeyIndex_%1: %2', FALSE, i, RecRef.KEYINDEX(i).FIELDINDEX(1).NAME) THEN; // >>> Result: i=1 - KeyIndex_1: Field_1 // i=2 - KeyIndex_2: Field_2 // // Seems to get "Active and Non-active Keys" IF CONFIRM('i=%1 - KeyIndex_%1: %2', FALSE, 3, RecRef.KEYINDEX(3).FIELDINDEX(1).NAME) THEN; // >>> Result: ERROR "Key index '3' out of range (must be within 1 through 2)." // // Seems to have no access to the last "Active Key"Is this a bug or am I doing something wrong? If it is not a bug … 1 - How do I get access to the “Last Active Key” 2 - How can I get access to the global table definition (Active and Non-active Fields/Keys)? 3 - If I can’t acces Non-active Fields/Keys, why exist in C/AL

  • Ok := FieldRef.ACTIVE
  • Ok := KeyRef.ACTIVE
    Thanks in advance for your comments.

Hi, this is a bug. If you search this forum you will find a threat, where this has been discused before. If i remember correctly, there is no workaround for this. Regards, Frank