Problem Description
I am working on creating a table and a page in Business Central using AL. Below is the table and page code I’ve implemented:
Table Code:
Page Code:
Errors Encountered
-
Error: The name 'No.' does not exist in the current context.
- This error occurs for the
field("No."; "No.")
line in the page code. - However, the
No.
field is properly defined in the table asfield(1; "No."; Code[20])
.
- This error occurs for the
-
Error: The name 'Department' does not exist in the current context.
- This error occurs for the
field("Department"; "Department")
line in the page code. - The
Department
field is also defined in the table asfield(2; "Department"; Text[30])
.
- This error occurs for the
-
Error: 'CurrPage.InsertRecord()' does not exist.
- This occurs in the
InsertNew
action of the page. - I’ve set the
PageType
toCard
, but theInsertRecord
method does not seem to work withCard
.
- This occurs in the
Steps I’ve Tried
-
Verified the Table Definition:
- Both
No.
andDepartment
fields are defined in the table. - The table has been saved and published successfully.
- Both
-
Changed the PageType:
- I attempted to change the
PageType
fromCard
toList
, but the issue persisted.
- I attempted to change the
-
Recompiled and Republished:
- The project was recompiled using
AL: Publish Without Debugging
. - No compilation errors were reported.
- The project was recompiled using
Expected Behavior
- The page should correctly display the
No.
andDepartment
fields from the table. - The
InsertRecord
action should allow adding new records to the table.
Questions
- Why is the page not recognizing the fields (
No.
,Department
) defined in the table? - How can I resolve the
'InsertRecord' does not exist
error for aCard
orList
page?
Any help or insights would be greatly appreciated!