Now, let’s look at an example of how to call a D365 find method.
In any method in the system, you can right click on the method definition and select ‘Find All References‘. Do this now. First, right click on the word ‘find’. Then, select ‘Find All References‘.
As can be see, the Find Symbol Results window will show locations in code where this method is called.
Locate and double click on the record /Classes/RetailTransactionServiceCustomer/Methods/updateCustomerFiscalCode
After double clicking on the result, a window will open showing the code. See screenshot above.
First, the code declares a table buffer of type ‘CustTable‘, with the name ‘custTable‘.
Second, the find method is called. And the result of that method is assigned to the table buffer variable.
In this instance, the ‘find’ method is a static method. Therefore, to call it use :: (colon colon) instead of a period. Next, pass in any parameter values used to find the record. Finally, when updating or deleting a record, pass in ‘true’ as the value for the parameter _forUpdate.
After setting the table buffer variable, a developer can read, update, or delete the record.
In the above code example, first the field FiscalCode is set. Then, the update() method is called on the table buffer. And finally, the ttscommit; causes the system to write the change to the database. .
Comments
Post a Comment