Friday, December 15, 2023

Selection changed and active method in Dynamics 365 FO

1. Selection Changed Method:

   - This method is triggered when the selection of a record in a grid or a form changes.

   - It is commonly used to handle scenarios where actions need to be taken based on the user's selection of a record. For example, enabling or disabling buttons, displaying additional details of the selected record in another form part, or refreshing data based on the new selection.

   - The Selection Changed method is associated with the form's data source and is typically overridden in the form's data source class.

2. Active Method:

   - The Active method is called whenever a record in a form is activated or when the focus is set on a record.

   - It's used to perform actions every time a record becomes active, which might not necessarily be due to a change in selection. For example, it can be used to display additional details of the record or to execute some logic related to the active record.

   - This method is also associated with the form's data source and can be overridden to provide custom logic whenever a record becomes active in the form.

In essence, while the "Selection Changed" method is specifically about the change in the selection of records, the "Active" method is more about a record gaining focus or becoming the currently active record, regardless of whether it was selected previously or not. Both are important in managing the behavior and interaction of forms in Dynamics 365 F&O.