Options

NAV 2017 Action Events - CurrPage.UPDATE

wittgensteinwittgenstein Member Posts: 17
Hi all,

I'm currently creating an Extension/App (upgrading an older solution). I added some page actions and created a Codeunit to handle the action events (OnBeforeActionEvent).
Is it possible to update the action calling page like it is in the action trigger of the page itself (-> CurrPage.UPDATE)? If not, maybe there is a work-around you know about?!

Thanks in advance.

Best Answer

  • Options
    wittgensteinwittgenstein Member Posts: 17
    Answer ✓
    OK I had an idea for a workaround. And it worked. It's not best practice but I made a few test scenarios and there were no errors.

    I just used SendKeys to send an 'F5' to the page. I used the DotNet solution as there is a popup when running an Automation for the first time.

Answers

  • Options
    KishormKishorm Member Posts: 921
    Unfortunately this is not possible because NAV doesn't pass the Page object to the event. I had a similar issue in that I wanted to make the page editable/non-editable via the OnOpenPageEvent() event - but without having a reference to the page itself - its not possible.

    I don't know of a work-around for this either.
  • Options
    wittgensteinwittgenstein Member Posts: 17
    Hi,

    that's sad news. I was hoping I missed something in the whole event thingy. Really unfortunate.

    Thanks for your answer anyway :-)
  • Options
    zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    Kishorm wrote: »
    Unfortunately this is not possible because NAV doesn't pass the Page object to the event. I had a similar issue in that I wanted to make the page editable/non-editable via the OnOpenPageEvent() event - but without having a reference to the page itself - its not possible.

    I don't know of a work-around for this either.

    @Kishorm to make page editable / non editable what you can do is to set a boolean variable on Editable property and make it true on OnInitPage() depend on some condition.

    Moreover you can also call one page function to another but make sure function should not be LOCAL. By calling that function you can set the value of that boolean variable.
    Best Regards
    Zohaib Ahmed
    Dynamics NAV ERP Technical Consultant.

    please like / agree / verify my answer, if it was helpful for you. thanks.
  • Options
    zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    @wittgenstein can you please elaborate more what you are trying to do? may be i can suggest you some work around?
    Best Regards
    Zohaib Ahmed
    Dynamics NAV ERP Technical Consultant.

    please like / agree / verify my answer, if it was helpful for you. thanks.
  • Options
    KishormKishorm Member Posts: 921
    zohaibu95 wrote: »
    Kishorm wrote: »
    Unfortunately this is not possible because NAV doesn't pass the Page object to the event. I had a similar issue in that I wanted to make the page editable/non-editable via the OnOpenPageEvent() event - but without having a reference to the page itself - its not possible.

    I don't know of a work-around for this either.

    @Kishorm to make page editable / non editable what you can do is to set a boolean variable on Editable property and make it true on OnInitPage() depend on some condition.

    Moreover you can also call one page function to another but make sure function should not be LOCAL. By calling that function you can set the value of that boolean variable.

    @zohaibu95 You're misunderstanding this post. I know how to set the Editable property on a Page - that's not what this is about. It's about how to achieve this by using Events in separate codeunits - i.e. WITHOUT changing the Page object itself.
  • Options
    zohaibu95@hotmail.comzohaibu95@hotmail.com Member Posts: 223
    ah, this is not possible as far as i know.
    Best Regards
    Zohaib Ahmed
    Dynamics NAV ERP Technical Consultant.

    please like / agree / verify my answer, if it was helpful for you. thanks.
  • Options
    KishormKishorm Member Posts: 921
    zohaibu95 wrote: »
    @wittgenstein can you please elaborate more what you are trying to do? may be i can suggest you some work around?

    @wittgenstein wants to add a new Action to a Page and within this action he wants to call the CurrPage.UPDATE to update the Page. However he wants to achieve this without making any changes to the Page object itself but by using Events mechanism introduced in NAV 2016.
  • Options
    wittgensteinwittgenstein Member Posts: 17
    Kishorm wrote: »
    @wittgenstein wants to add a new Action to a Page and within this action he wants to call the CurrPage.UPDATE to update the Page. However he wants to achieve this without making any changes to the Page object itself but by using Events mechanism introduced in NAV 2016.

    That's exactly what I want. Even though it is possible in extensions to add new actions you can't add code to the actions' triggers. This is why I wanted to solve this with events.

    So I chose the OnBeforeActionEvent and added my code. Unfortunately NAV doesn't pass the page object to the event so you are not able to make an update (CurrPage.UPDATE) on the page.
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    this is one of the limitations extensions1.0
    we need to wait for extensions 2.0 which is in preview
  • Options
    wittgensteinwittgenstein Member Posts: 17
    Answer ✓
    OK I had an idea for a workaround. And it worked. It's not best practice but I made a few test scenarios and there were no errors.

    I just used SendKeys to send an 'F5' to the page. I used the DotNet solution as there is a popup when running an Automation for the first time.
Sign In or Register to comment.