Override a System Defined Refresh button in D365O
Essentially this post is going to discuss calling custom code while refreshing a form in D365O, however, you can find more information about other system defined buttons and how you can run extra code or suppress them in this article: System-Defined buttons
Firstly the datahelper() method of the formRun framework class can be used to provide services that allow managing the datasources of the form.
How can I add custom code to run when I click refresh?
We are going to use eventing (pre-event handler and post-event handler) to do this:
1. Write your method that you want to call when the refresh button is clicked
2. In the Form.int subscribe using the datahelper().Refreshing event
3. On refresh click you'll see your message
Firstly the datahelper() method of the formRun framework class can be used to provide services that allow managing the datasources of the form.
How can I add custom code to run when I click refresh?
We are going to use eventing (pre-event handler and post-event handler) to do this:
1. Write your method that you want to call when the refresh button is clicked
2. In the Form.int subscribe using the datahelper().Refreshing event
3. On refresh click you'll see your message
Did you try to customize a Post Button event handler? I'm new in D365FO, I would like to add my own code after click event finished.
ReplyDeleteThanks in advance.
I'm assuming the post button is not a system defined button. You can use a onClick event handler from the Post Button on the form designer and write your code in the event handler
DeleteHow we ovveride or extend the functionality on SystemDefinedPopoutButton
DeleteYou can look into doing something similar to this (copied from BudgetPlan form init method):
DeleteFormCommandButtonControl attachmentButton = this.control(this.controlId(BudgetPlanningConstants::SystemDefinedAttachButton)) as FormCommandButtonControl;
if (attachmentButton)
{
BudgetPlanFormHelper formHelper = BudgetPlanFormHelper::construct();
formHelper.parmBudgetPlanHeader(budgetPlanHeader);
attachmentButton.registerOverrideMethod(methodStr(FormCommandButtonControl, clicked), methodStr(BudgetPlanFormHelper, attachButtonClicked), formHelper);
}