In this blog post, I will show you how to write the find method on the table in D365FnO using x++.
The find method is used to retrieve a record from a table based on a primary key value. It is a static method that belongs to the table and returns an instance of the table buffer.
To write the find method on the table in D365FnO using x++, you need to follow the following code:
public static BookingTable find(BookingId _bookingId,
boolean _forupdate = false,
ConcurrencyModel _concurrencyModel = ConcurrencyModel::Auto)
{
BookingTable bookingTable;
bookingTable.selectForUpdate(_forupdate);
if (_forupdate && _concurrencyModel != ConcurrencyModel::Auto)
{
bookingTable.concurrencyModel(_concurrencyModel);
}
select firstonly bookingTable
where bookingTable.BookingId == _bookingId;
return bookingTable;
}
Save and compile your code.
You have successfully written the find method on the table in D365FnO or AX2012 using x++. You can now use this method in your code to retrieve records from your table based on their primary key values.