AX – D365FO – Methods on a Form Data Source

Original document from Microsoft documentation : https://docs.microsoft.com/en-us/dynamicsax-2012/developer/methods-on-a-form-data-source

Each form data source has a set of standard methods. You override these methods when you want to change the behavior for validation, caching, and so on. These methods are a subset of the methods in the FormDataSource system class.

You use the AOT to access the standard methods:

  1. Expand the node for the form data source on the form.
  2. Right-click the Methods node.
  3. Select Override Method.

 Note

Code written on forms cannot be re-used or inherited. If possible, write your code on the underlying table or in a class.

The following table lists the methods that are available for form data sources and explains when they are executed. For more information about each method, click the method name.

Method nameExecuted whenDescription
activeThe user selects a new record.Retrieves data from joined data sources when a user moves to a new record.
createThe user creates a new record in the data source.Creates a new record in the data source.If you use this method to specify field values, the new values are saved to the database when you leave the form.
cursorNotifyNot run by the system.Used to notify application code of table events.
defaultMarkThe user clicks the mark area (uppermost left corner) in a grid control.Sets the default mark value for records in a form.
deletedThe form data source record has been deleted.Runs instead of the delete post-super for a form where the ChangeGroupMode property of the form Data Sources node is set to ImplicitInnerOuter.
deleteThe user deletes a record in the data source.Deletes the current record from the data source.
deleteMarkedThe user deletes one or more marked (selected) records in the data source.Deletes all marked (selected) records from a data source.
deletingThe form data source record is about to be deleted.Runs instead of the delete pre-super for a form where the ChangeGroupMode property of the form Data Sources node is set to ImplicitInnerOuter.
displayOptionActivated before a record is displayed.Sets the text color and the background color for a record in the data source.
executeQueryThe form is opened for data display.Executes the data source query and displays the retrieved records.
filterThe user starts one of the Filter commands on the form shortcut menu.Filters records in the data source.
findRecordActivated by the findValue method.Finds the specified record in the data source and makes it the current one.
findValueThe user clicks the Filter by Field command in the shortcut menu on a form control.Finds the specified value in the data source and makes the record that has the specified value the current one by using the FormDataSource.findRecord method.
firstFocus moves to the first record in the data source.Moves focus to the first record in the data source.
forceWriteExecuted when it is called.Enables you to force a write operation on a record.
initThe form is opened.Creates a data source query based on the data source properties.
initValueA new record is created. The purpose is to fill in initial values in the record.Initializes field values in a new record.If you use this method to specify field values, the new values are not automatically saved to the database when you leave the form. To specify values that you want to save when you leave the form, use the Create method.
lastFocus moves to the last record in the data source.Moves focus to the last record in the data source.
leaveFocus moves to a new record or to a new data source.Provides notification when focus is moved to the next record or moved to another data source.
leaveRecordFocus moves to a new record.Provides notification when focus moves to another record or another item on the form.
linkActiveThe user selects a new record in a form that has a data source linked to another data source.Calls the FormDataSource.exeuteQuery method on data sources that are linked to the current data source.
markA record in the data source is marked.Enables you to mark a record in the data source.
markAllLoadedRecordsNot started by the system.Enables you to mark or clear all the loaded records.
markChangedOne or more records in the data source are marked or unmarked.Enables you to perform an action when there is a change to the number of marked records in the data source.
nextFocus moves to the next record in the data source.Moves focus to the next record in the data source.
nextPageThe user requests the next page of data from the data source.Moves a specified number of records forward in the data source. Pulls the next page of data.
prevFocus moves to the previous record in the data source.Moves focus to the previous record in the data source.
prevPageThe user requests the previous page of data from the data source.Moves focus back by a specified number of records in the data source. Pulls the previous page of data.
printThe user starts the Print command in the File menu.Prints the current record.
promptThe user starts the Advanced Filter/Sort command (either from the Edit > Filter menu or by pressing CTRL+F3).Activates SysQueryForm, which is the standard form used to limit a query range.
refreshNot started by the system.Updates the form by refreshing the view of all records in the data source.
refreshExA form is opened where records have been selected.Refreshes the view of the specified records.
removeFilterThe user clicks the Remove Filter/Sort command in the shortcut menu on a form control.Resets the query for the data source.
rereadNot started by the system.Rereads the current record from the database.
rereadReferenceDataSourcesThe value of a foreign key field is programmatically changed.Used to update the joined referenced data source for the current record when the foreign key field is programmatically changed.
researchNot started by the system.Refreshes the database search defined by the query, specified by the FormDataSource.init method.
selectionChangedThe user selects or unselects one or more records in the data source.Enables you to change the property values of control when the selected record changes.
validateDeleteThe user has chosen to delete a record.Requests the user to confirm the deletion of a record from the data source.
validateWriteA new or updated record is to be written.Determines whether data is valid and ready to be written.
writeThe user inserts a new record or updates an existing one.Calls the FormDataSource.validateWrite method and manages the database write operation.
writingThe form data source record is about to be saved to the database.Runs instead of the write pre-super for a form where the ChangeGroupMode property of the form Data Sources node is set to ImplicitInnerOuter.
writtenThe form data source record has been saved to the database.Runs instead of the write post-super for a form where the ChangeGroupMode property of the form Data Sources node is set to ImplicitInnerOuter.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s