Hi,
We are in the middle of migrating from C/AL to AL. As a first step we are replacing as much custom code with events.
Now I am working on a page with a custom action. The code beind is:
- Execute a Function in a Codeunit, Rec is passed as VAR
- This codeunit changes the Rec
- CurrPage.UPDATE, changes are reflected on the page
Now obiously, the CurrPage.UPDATE can not be used inside an event function. However, I was kind of hoping that after firing an OnAfterActionEvent event, Dynamics Nav would trigger the CurrPage.UPDATE itself. This would make sense since the Rec is passed as a VAR parameter. However, I have tested it and no CurrPage.UPDATE is triggered.
Does anyone has an idea how to go about this? And would you agree that Dynamics Nav (BC) should issue a CurrPage.UPDATE?
We are on Business Central 2018 CU3.
Thanks!
Answers
Anyway, if I understand correctly, you have something like this:
And the problem being that you cannot call CurrPage.Update(true/false), because you're not on the Page, but in a separate codeunit.
But you can also "hook up" to Page Actions (before and after execution) on the page level, by modifying the required action, and adding trigger OnAfterAction or OnBeforeAction:
You put your code there, and you don't need an Event Subscriber at all!
Thanks for your time and answer!
At the moment we don't have any AL code yet. We first want to decrease our custom C/AL code by introducing events. When we are done we can convert out C/AL to AL.
I was hoping to be able to force a page refresh, in order to reduce the amount of custom AL code. But apperantly this is not possible.