Showing posts with label ChainOfCommand. Show all posts
Showing posts with label ChainOfCommand. Show all posts

Wednesday, December 1, 2021

How to call standard button Clicked method from customized button in D365FO

Hi Guy's,

Recently, I received one requirement where we need standard button clicked method logic to be called from customized button on the same form but in another Action Pane Tab and button group.

To achieve this requirement, I used COC of the form and retrieve the button control in variable. I easily able to call the method's define on the button.

Please check below code.

[ExtensionOf(formStr(WHSLoadTable))]
final class WHSLoadTableForm_Extension
{

[FormControlEventHandler(formControlStr(WHSLoadTable, PickList), FormControlEventType::Clicked)]
public static void PickList_OnClicked(FormControl sender, FormControlEventArgs e)
{
        FormButtonControl callerButton = sender as FormButtonControl;

                  FormRun form = callerButton.formRun();

                  FormButtonControl btnPickList = form.design(0).controlName("WHSPickListShipping") as                 FormButtonControl;

                btnPickList.clicked();

        }
}

Happy Learning !!