Table Methods in D365 F&O

Rumman Ansari   Software Engineer   2023-10-25   5615 Share
☰ Table of Contents

Table of Content:


In Microsoft Dynamics 365 Finance and Operations, table methods are used to perform specific operations on a table. They are defined within the table itself and can be called from any other object within the application.

Table methods can be used to perform tasks such as data validation, calculations, and database operations. They are often used in combination with form methods and class methods to provide functionality to the user interface and business logic of the application.


Some common types of table methods in Microsoft Dynamics 365 Finance and Operations include:
  1. ValidateField: This method is called when a field value is changed, and it can be used to validate the new value and set error messages if necessary.
  2. Write: This method is used to write data to the database. It is typically called after data has been changed in a form or other user interface element.
  3. Delete: This method is used to delete a record from the database.
  4. CalculateFields: This method is used to calculate values for fields based on other fields in the table. It can be called after data is entered or changed to ensure that all calculations are up-to-date.
  5. InitValue: This method is used to initialize field values when a new record is created.

Here is an example of a table method in Microsoft Dynamics 365 Finance and Operations:


public void validateField(FieldId _fieldId)
{
    if (_fieldId == fieldNum(MyTable, MyField))
    {
        if (this.MyField <= 0)
        {
            this.MyField = 1;
            warning("MyField value cannot be less than or equal to zero. Value has been set to 1.");
        }
    }
}

In this example, the "validateField" method is called when the "MyField" value is changed. If the new value is less than or equal to zero, the method sets the value to 1 and displays a warning message to the user.

Table Methods - Standard table - CustGroup

Table Methods - Standard table - CustGroup
Figure: Table Methods - Standard table - CustGroup

Table Methods - Standard table - CustTable

Table Methods - Standard table - CustTable
Figure: Table Methods - Standard table - CustTable


Screenshots for Custom/User-defined Table Methods

Table Methods in D365 F&O
Figure:


Table Methods in D365 F&O
Figure:


Table Methods - Standard table - CustTable - Event Handler

Table Methods - Standard table - CustTable - Event Handler
Figure: Table Methods - Standard table - CustTable - Event Handler


Custom Table - View code

Custom Table - View code
Figure: Custom Table - View code