9 Jun’17

Dynamics 365, Enterprise, Dynamics AXOverride Form DataSource method using Extensions in D3fO

In this blog article, we will see how we can override Form Data source method using Extensions in Dynamics 365 Operations. Now as recommended by Microsoft we must avoid Overlayering and instead use Extension. For extension, we have to use pre or post event handlers methods. In this blog we will create event handler of OnActivated() method of SalesLine DataSource of form SalesTable.

Create a new Class:

class CFSActivateButton


Copy and paste OnActivated() event handler of SalesTable DataSource in Class:


/// <summary>
/// To activate or deactivate Create Service Order button based on CFSProjId field of SalesLine
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

[FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::Activated)]
public static void SalesLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)

        FormDataSource      fds = sender.formRun().dataSource("SalesLine");
        SalesLine           salesline = fds.cursor();
        FormRun             fr = sender.formRun();
        FormControl         fc = fr.design(0).controlName("CreateServiceOrder");       



Written by

Sohagani Shah

ERP Developer

3 thoughts on “Override Form DataSource method using Extensions in D3fO”

  1. I tried overriding form data source active method using OnActivated event handler but the event handler runs first then the standard active method code runs after hence can’t override. Is there another way of archiving this?

    1. Hi Percy,

      It seems you are using event handler ‘OnActivated()’ of form and not form DataSource as Form -> FormDatasource -> EventHandler ‘OnActivated()’ is always triggered after standard formdatasource active() method.

      Can you tell us the exact scenario you are trying so we can better help you?

  2. Hi,

    I was able to achieve this by using OnMarkChanged event as OnActivated runs before the standard active method of the data source.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • Reading more then 10K records in D3FOE OData API

    11 July’ 2018

    Introduction: We all know Dynamics 365 Finance and Operations has limitation of 10K records to be fetched at a time usi...

    Read more
  • Paging in D365 Customer Engagement v9.0

    10 July’ 2018

    Introduction: The Xrm.retrieveMultipleRecords method is used to retrieve a collection of records in Dynamics 365 Custom...

    Read more
  • Set up Dynamics 365 connection in Microsoft Social Engagement

    10 July’ 2018

    Introduction: This blog explains how to Set up Dynamics 365 connection in Microsoft Social Engagement. Steps to be follo...

    Read more
  • Voice of the Customer failed to install

    10 July’ 2018

    Introduction: Many people face issues in installing Voice of Customer solution on v9 environment and trying repeatedly ...

    Read more
  • Scribe Insight AX as a Web Service Find Block issue

    10 July’ 2018

    Introduction: If we need to look up for any value from AX then we do it by using a Find Block in Scribe Insight Eg: Basi...

    Read more