Retrieving data using FIND
Once you have determined the data that you want to operate on, you must retrieve it from the database. Most of the time the action to be performed must be performed on more than one record. This recipe will show you the best ways to get that data and when certain methods should be used.
How to do it...
Create a new codeunit from Object Manager.
Add the following local variable to the
OnRun
trigger:Name
Type
Subtype
Customer
Record
Customer
Add the following code to your
OnRun
trigger:IF Customer.FINDFIRST THEN MESSAGE('The first customer in the database is:\No.: %1\Name: %2', Customer."No.", Customer.Name); IF Customer.FINDLAST THEN MESSAGE('The last customer in the database is:\No.: %1\Name: %2', Customer."No.", Customer.Name); IF Customer.FINDSET THEN BEGIN MESSAGE('There are %1 customers in the database', Customer.COUNT); END;
Save and close the codeunit.
When you run the codeunit you will see windows that look like the following:
How it works...
There...