Microsoft Dynamics NAV table fields not found

1.8k views Asked by At

I have created two new tables in our Dynamics NAV 2013 installation: 50086 Order By Period and 50089 Item Sales By Period. Each contains Date, Decimal, Integer and Text fields, as well as the Code fields used in the key. I left all field properties as their defaults. When referring to the tables in my codeunit some, but not all, of the fields cause compile errors because they are not recognised, with the error "You have specified an unknown variable." In the codeunit I have the tables referenced as local variables of type Record.

I have tried a number of different ways of referring to the table fields in case the error was in the code but all cause the same error. My current code is:

ItemRevenue.VALIDATE("Last Period Orders", 1);

Recompiling the objects (tables and codeunit) has not fixed the problem. In order to force the compiler to use the latest version of the tables I have removed all references to the tables from the codeunit, recompiled the tables, then added the references back and recompiled the codeunit. This hasn't corrected it, the same fields are still causing compile errors.

All the table fields are present in the SQL Server tables.

What should I do to make all the new table fields visible to the compiler?

2

There are 2 answers

2
Valerie Metcalf On BEST ANSWER

I never worked out why the compiler didn't recognise the table field names but using the C/AL Symbol Menu to add the field names instead of typing them, or copying and pasting them from the table definition, created compilable code. To the human eye there was no difference in the field names but the compiler recognised the field names inserted via the C/AL Symbol Menu whereas it hadn't recognised them before.

0
Mak Sim On

If you adding fields to table while having codeunit referencing the table opened then C/AL will throw this error until you reopen codeunit. This is the only way to refresh table definition for codeunit.

However if the codeunit declared as SingleInstance then just reopen codeunit is not sufficient. You have to restart client application or as it called in newer versions Development Environment. That will refresh table definition for singleinstance codeunit.