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()
{
super()
buffer.method();
}
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)
{
//mycustomermethod();
}
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 {
buffer.method();
}
exception::error or Waring
{
give the same error/or warning message the method gives.
}
else
{
//execute my code.
}
. how do i call the method already called in base form clicked.
thanks.
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.
docs.microsoft.com/.../method-wrapping-coc
thanks,
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.
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.