Options

Page OnAfterActionEvent not refreshing page

rcverbeekrcverbeek Member Posts: 32
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:
  1. Execute a Function in a Codeunit, Rec is passed as VAR
  2. This codeunit changes the Rec
  3. 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

  • Options
    ShaiHuludShaiHulud Member Posts: 228
    I disagree that NAV/BC should automatically call CurrPage.Update(true/false), because then you wouldn't have control over it.

    Anyway, if I understand correctly, you have something like this:
    tmjhdawph4zs.png
    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:
    bt69nvt7hn10.png

    You put your code there, and you don't need an Event Subscriber at all!
  • Options
    rcverbeekrcverbeek Member Posts: 32
    Hi ShaiHulud,

    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.
Sign In or Register to comment.