Skip to main content



No record found.

Dynamics 365 Community / Forums / Finance forum / Call method of button ...
Finance forum

Call method of button event handler

Posted on by 452

HI All,

 I need to execute a custom code based on a standard method code result, the standard method is on a button control in a form,

Public clicked()





I have created a clicked event handler in an extension

[FormControlEventHandler(formControlStr(HcmWorker, ArgsExampleButton), FormControlEventType::Clicked)]
public static void ArgsExampleButton_OnClicked(FormControl sender, FormControlEventArgs e)


not what i want to achieve is , my custom code to be triggered based on the successful execution of  buffer.clicked() in the standard clicked method. since the buffer.code does not return anything i thought of using error handling to achieve this,

try {



exception::error or Waring


give the same error/or warning message the method gives.




//execute my code.


. how do i call the method already called in base form clicked.


  • Karunakaran nainar Profile Picture
    Karunakaran nainar 452 on at
    RE: Call method of button event handler

    Hi Nikolaos and Sumit,

    Thanks for your responses, i tried to search on the suggesged lines I got the below link were we can use try catch on Next() call.


  • Verified answer
    Sumit Loya Profile Picture
    Sumit Loya 2,230 on at
    RE: Call method of button event handler

    Hi Karunakaran,

    You can either create a CoC for clicked method of form control as suggested by Nikolaos or you can also create CoC of the buffer.method() if it is possible and use next() in try-catch block. Please note that latest versions of D365 allow next call to be in try-catch block.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Call method of button event handler

    I'm not sure if I understand your requirement.

    Anyway your event handler code will always be executed after the super() call of the clicked method of the standard button. This is because the "Clicked" event is fired in/after the super() call.

    So, you can't conditionally run your event handler method, based on what happens in buffer.method().

    However I think you could use Chain of Command on the clicked method, and be able to run your code only after the whole clicked method has been executed. And then you could even try to add a try catch around the "next" call.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans