web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :

Override Form DataSource method using Extensions in D3fO

Community Member Profile Picture Community Member

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");       

        if(salesLine.ProjID)
        {
            fc.enabled(true);
        }
        else
        {
            fc.enabled(false);
        }
    }

 

The post Override Form DataSource method using Extensions in D3fO appeared first on CloudFronts - Microsoft Dynamics 365 | Power BI | Azure.

Comments

*This post is locked for comments