When dealing with data you usually do not want to have to look at all of it. Most of the time you have a specific set of data from a table that you want to operate on. In NAV you can set filters on the records so that only the data that you want is returned.
Create a new codeunit from Object Designer.
Create a new function called
CheckForCustomer
. This function should take in the following parameter:Name
Type
Subtype
Cust
Record
Customer
Add the following code to this function:
IF Cust.FINDFIRST THEN MESSAGE('Found!\No.: %1\Name: %2\Filters: %3', Cust."No.", Cust.Name, Cust.GETFILTER(Name)) ELSE MESSAGE('Not Found!\Filters: %1', Cust.GETFILTER(Name));
Add the following local variable to the
OnRun
trigger:Name
Type
Subtype
Customer
Record
Customer
Add the following code to the
OnRun
trigger of your codeunit:Customer.SETCURRENTKEY(Name); Customer.SETFILTER(Name, '%1', 'The Cannon Group PLC'); CheckForCustomer(Customer); Customer.SETFILTER...