Key information

Hi all Nav-hackers! Does anyone know if it’s possible to get table key information via c/al - code? Best regards Torbjörn.

shift + F12, select table, design, menu View, Keys… But I think you meant a faster way (under F5) and that’s not possible… [:(]

Have you tried Rec.CURRENTKEY ? Or do you want to know all the keys belonging to a table?

Yes, I want to know all the keys in a table. I thought there was a virtual table for this info, but obvious there isn’t. /Torbjörn.

You are right, but there is (as always) a trick! Try this: RecRef.OPEN(TableID); FOR i := 1 TO RecRef.KEYCOUNT DO KeyName[i] := FORMAT(RecRef.KEYINDEX(i)); Int.SETRANGE(Nummer, 1, i); CLEAR(DatabaseKeys); DatabaseKeys.SetKeyNames(KeyName); DatabaseKeys.SETTABLEVIEW(Int); DatabaseKeys.RUNMODAL; DatabaseKeys.GETRECORD(Int); i := Int.Nummer; KeyID := i; Key := KeyName[i]; This shows the keys in a temporary form, based on the integer table. Succes.

A virtual key table will be available in 4.0 SP1, just for your info.

quote:

A virtual key table will be available in 4.0 SP1, just for your info.
Originally posted by robertc - 2005 Sep 09 : 20:15:18

What is the table ID? I cannot find it [:(]

Hi Mark Hope you are well? Thanks for the following code… RecRef.OPEN(TableID); FOR i := 1 TO RecRef.KEYCOUNT DO KeyName[i] := FORMAT(RecRef.KEYINDEX(i)); In 3.70 for TableID = 21, RecRef.KEYCOUNT returns 11 but if you check the key for table 21 there are 17 keys. The 11 is the number of active keys. How can you use the above to only report on all of the active keys in table 21 and not just the 1st 11 that it finds? Cheers David

The Key table has the secret ID of 2000000063. One of the BIG Navision secrets [:D]

Hi Thomas, The Key table has the secret ID of 2000000063. One of the BIG Navision secrets! I take it that that Table ID is only applicable in version 4.00 SP1 and not in 3.70? Cheers David

Correct, that is what Robert referred to.

So there is no solution for us poor 3.70 users?

Yeap, do a technical upgrade to Navision 4.0 SP1 (just exchange the server and client directories with the 4.0SP1 version (if you have a maintenance agreement)

Okay, thanks Thomas, Wish me luck!

Wow Thomas, You weren’t kidding, when I did a technical upgrade to Navision 4.0 SP1 virtual TableID 2000000063 was there in all its glory! Lucky I had that maintenance agreement to hand! Cheers and enjoy your weekend David

Incidentally Thomas, why doesn’t filtering on the TableNo work… //KeyKey := TableID := 2000000063; KeyKey.SETRANGE (TableNo, 21); //KeyKey.SETFILTER (TableNo, ‘21’); //KeyKey.SETFILTER (TableNo, ‘%1’, 21); IF KeyKey.FIND (’-’) THEN REPEAT //IF (KeyKey.TableNo = 21) AND KeyKey.Enabled THEN MESSAGE (’(%1)(%2)(%3)(%4)’, KeyKey.TableNo, KeyKey.“No.”, KeyKey.TableName, KeyKey.Key); UNTIL KeyKey.NEXT = 0;