hljs.configure({cssSelector: "code"}); hljs.highlightAll();

Friday, November 27, 2020

Form Event handler methods in Dynamics 365 FO

FormDataSourceEventHandler:

[FormDataSourceEventHandler(formDataSourceStr(CustGroup, CustGroup), FormDataSourceEventType::Activated)]

    public static void CustGroup_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)

    {

        FormRun formRun                = sender.formRun();

        FormDesign formDesign = formRun.design();

        FormButtonControl TestButton = formDesign.controlname('TestButton');

        CustGroup CustGroup = formRun.dataSource().cursor();

        TestButton.enabled(CustGroup.Name != '' );

    }

FormEventHandler:

     [FormEventHandler(formStr(CustGroup), FormEventType::Closing)]

    public static void CustGroup_OnClosing(xFormRun sender, FormEventArgs e)

    {

       FormDataSource ecoResProduct_ds   =                    sender.dataSource(formDataSourceStr(CustGroup,CustGroup));

        CustGroup      custGroup = ecoResProduct_ds.cursor();

       //Write your logic here

    }

FormControlEventHandler:

    [FormControlEventHandler(formControlStr(CustGroup, TestButton),  FormControlEventType::clicked)]

    public static void clicked_OnModified(FormControl sender, FormControlEventArgs e)

    {

       custgroup  custgroup;

      custgroup = sender.formrun().datasource().cursor();

      //Write your Logic here

   }