Share via


Methods on a Form Data Source

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

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 name

Executed when

Description

active

The user selects a new record.

Retrieves data from joined data sources when a user moves to a new record.

create

The 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.

cursorNotify

Not run by the system.

Used to notify application code of table events.

defaultMark

The user clicks the mark area (uppermost left corner) in a grid control.

Sets the default mark value for records in a form.

deleted

The 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.

delete

The user deletes a record in the data source.

Deletes the current record from the data source.

deleteMarked

The user deletes one or more marked (selected) records in the data source.

Deletes all marked (selected) records from a data source.

deleting

The 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.

displayOption

Activated before a record is displayed.

Sets the text color and the background color for a record in the data source.

executeQuery

The form is opened for data display.

Executes the data source query and displays the retrieved records.

filter

The user starts one of the Filter commands on the form shortcut menu.

Filters records in the data source.

findRecord

Activated by the findValue method.

Finds the specified record in the data source and makes it the current one.

findValue

The 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.

first

Focus moves to the first record in the data source.

Moves focus to the first record in the data source.

forceWrite

Executed when it is called.

Enables you to force a write operation on a record.

init

The form is opened.

Creates a data source query based on the data source properties.

initValue

A 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.

last

Focus moves to the last record in the data source.

Moves focus to the last record in the data source.

leave

Focus 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.

leaveRecord

Focus moves to a new record.

Provides notification when focus moves to another record or another item on the form.

linkActive

The 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.

mark

A record in the data source is marked.

Enables you to mark a record in the data source.

markAllLoadedRecords

Not started by the system.

Enables you to mark or clear all the loaded records.

markChanged

One 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.

next

Focus moves to the next record in the data source.

Moves focus to the next record in the data source.

nextPage

The 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.

prev

Focus moves to the previous record in the data source.

Moves focus to the previous record in the data source.

prevPage

The 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.

print

The user starts the Print command in the File menu.

Prints the current record.

prompt

The 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.

refresh

Not started by the system.

Updates the form by refreshing the view of all records in the data source.

refreshEx

A form is opened where records have been selected.

Refreshes the view of the specified records.

removeFilter

The user clicks the Remove Filter/Sort command in the shortcut menu on a form control.

Resets the query for the data source.

reread

Not started by the system.

Rereads the current record from the database.

rereadReferenceDataSources

The 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.

research

Not started by the system.

Refreshes the database search defined by the query, specified by the FormDataSource.init method.

selectionChanged

The 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.

validateDelete

The user has chosen to delete a record.

Requests the user to confirm the deletion of a record from the data source.

validateWrite

A new or updated record is to be written.

Determines whether data is valid and ready to be written.

write

The user inserts a new record or updates an existing one.

Calls the FormDataSource.validateWrite method and manages the database write operation.

writing

The 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.

written

The 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.

See also

FormDataSource Class

Methods on a Form

Methods on Form Controls

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.