Find method:
In Microsoft Dynamics 365 Finance and Operation we have a table method called as find method, to find/fetch the unique record from a table, depending on the primary key. It is also best practice to create find method in table in Microsoft Dynamics 365 Finance and Operations. In a find method we have 2 input parameters one is the primary key for the table, which is mandatory input parameter and second is boolean which basically defines if you want to enable selectForUpdate or not.
Benefits of the D365 Find method:
Find method is a practical and optimized approach for retrieving records based on key fields in Dynamics 365 FO. Benefits are as follows:
Efficient Retrieval: Retrieving records based on primary or unique keys, making it fast and efficient.
Readability: By using the find method, the intent of the code is clear to other developers, improving maintainability and readability.
Supports forUpdate: Selected record can be updated once selected.
Understanding the parameters:
We usually have 2 parameters in Find method, 1st parameter
Primary key: That is unique for every record in the table.
forUpdate: This is basically a boolean parameter which tells if the data that is selected, it needs to be updated at the same time or not. If boolean value is true, it means we can update the value and if the boolean value is false then we can’t update the value.
Example of D365 Find method:
/// <summary>
/// Find method for the Standard table.
/// </summary>
/// <param name="_standard">
/// The <c>_standard</c> value that specifies the standard
/// </param>
/// <returns>
/// true then returns Standard Table
/// </returns>
static LSStandardTable find(LSStandard _standard,
boolean _forUpdate = false)
{
LSStandardTable standardTable;
if (_standard)
{
if (_forUpdate)
{
standardTable.selectForUpdate(_forUpdate);
}
select firstonly standardTable
index hint StandardIdx
where standardTable.StandardCode == _standard;
}
return standardTable;
}
Above code, just add it in methods node of respective Table as shown below

Exist method:
In Microsoft Dynamics 365 Finance and Operation we have a table method called as exist method, to check if the record exist in the table, depending on the primary key. It is also best practice to create exist method in table in Microsoft Dynamics 365 Finance and Operations. In a exist method we have 1 input parameters one is the primary key for the table, which is mandatory input parameter.
Benefits of the D365 Exist method:
Exist method is a practical and optimized approach for checking if records based on key fields in Dynamics 365 FO exists or not.
Understanding the parameters:
We usually have 1 parameters in exist method,
Primary key: That is unique for every record in the table.
Example of D365 Exist method:
/// <summary>
/// Checks if a record exists in the LSStandardTable based on the given standard.
/// </summary>
/// <param name="_standard">
/// The <c>_standard</c> value that specifies the standard to be checked.
/// </param>
/// <returns>
/// Returns <c>true</c> if a record with the specified standard exists in the LSStandardTable; otherwise, <c>false</c>.
/// </returns>
static boolean exist(LSStandard _standard)
{
return _standard && (select firstonly RecId from LSStandardTable
index hint StandardIdx
where LSStandardTable.StandardCode == _standard).RecId != 0;
}
Above code, just add it in methods node of respective Table as shown below

You can also check out my previous blog: D365 Edit method
Need help? Connect Atul
- D365 Data entitiy Insert method COC - October 30, 2024
- D365 Joins - October 16, 2024
- D365 Find method and Exist method - October 9, 2024