Writing less expensive C/AL code for customizations
There are a few considerations to keep in mind while writing a customized C/ AL code, as poorly written code can affect the performance of the application or a business process significantly.
Retrieving data using FINDFIRST/FINDLAST/FINDSET
Using FINDFIRST
instead of the following FIND('-')
statement is also an inexpensive command to retrieve the first record from the recordset.
The following is the code for retrieving the first record using the FIND
statement:
GLEntry.SETRANGE(...); IF NOT GLEntry.FIND('-') THEN MESSAGE('No entries in the GL Entry table');
The previous code can be replaced with the following code:
GLEntry.SETRANGE(...); IF NOT GLEntry.FINDFIRST THEN MESSAGE('No entries in the GL Entry table');
Using FINDLAST
instead of the following FIND('+')
is an inexpensive way to retrieve the last record from the recordset.
The following is the code for retrieving the last record using the FIND('+')
statement:
GLEntry.SETRANGE(...); IF...