We have now covered everything that is necessary for our squash court application to run but there is one special function of Microsoft Dynamics NAV that needs changing when we add new documents and ledger entries: the Navigate
function.
The functionality was already discussed in Chapter 1, Introduction to Microsoft Dynamics NAV. The object is a single page (344) in the application that requires two changes.
The first function we change is FindRecords
. This browses through the database finding all possible combinations of document no. and posting date.
FindRecords()
...
// Squash Ledger Entries
IF SquashLedgEntry.READPERMISSION THEN BEGIN
SquashLedgEntry.RESET;
SquashLedgEntry.SETCURRENTKEY("Document No.",
"Posting Date");
SquashLedgEntry.SETFILTER("Document No.",DocNoFilter);
SquashLedgEntry.SETFILTER("Posting Date",PostingDateFilter);
InsertIntoDocEntry(
DATABASE::"Squash Ledger Entry",0,
SquashLedgEntry.TABLECAPTION,SquashLedgEntry.COUNT);
END;
// Squash Ledger Entries
DocExists := FINDFIRST;
The function first checks if we have permission to read the squash ledger entry table. If our system administrator does not allow us to see this table, it should not show up.
The filtering is done on the document no. and posting date. When ready, the system inserts the number of found records in the result table.
The second function to change is ShowRecords
. This makes sure we see the squash ledger entries when we click on the Show action.
ShowRecords()
...
DATABASE::"Warranty Ledger Entry":
FORM.RUN(0,WarrantyLedgerEntry);
//* Squash Ledger Entries
DATABASE::"Squash Ledger Entry":
FORM.RUN(0,SquashLedgEntry);
END;
END;