Identify the "current" page from a code unit

bknoppbknopp Member Posts: 37
edited 2014-07-01 in NAV Three Tier
Hi, all - I'm back :D

I've recently made a very cool modification to Dimension handling, whereby the user can go to one dimension group and, for values in that dimension "controlling" group, set defaults for two other dimension groups. Then, when the user changes the value in the "controlling" group, the other two dimension group values are set to the corresponding defaults. It's very cool, if I do say so myself, and all the logic is in Code Unit 408 (except for the table and page, of course).

However, there's an issue with that. When the user is in, say, the Purchase Order Subform, editing the detail lines of the PO, the dimension changes don't show until the page is refreshed.

Now, given that the "path" to my logic is Purchase Order Subform -> Purchase Lines table -> Dimension Management code unit, how do I force the Purchase Order Subform to refresh? I tried "CurrPage.Refresh", but NAV told me that CurrPage didn't exist. I don't want to put the call on the Purchase Order Subform, because I'd then have to modify a bunch of other forms as well, AND remember to add the call to any dimension-aware forms that I make.

So here's my question: when a user goes Page -> Table -> Code Unit, is there a way in the Code Unit to identify the page that's a couple of abstraction layers up?

Answers

  • ara3nara3n Member Posts: 9,256
    you can try this solution. It's a workaround.

    http://dynamicsuser.net/blogs/mark_brum ... -page.aspx
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • bknoppbknopp Member Posts: 37
    Thanks, ara3n. I'll give that a try this afternoon :)
  • bknoppbknopp Member Posts: 37
    :(

    I tried that workaround and got error to the effect that I could not create the automation server. I created the WshShell object as an Automation with a subtype of 'Windows Script Host Object Model'.IWshShell3 - that was the only object that made sense in the context of that page.

    Any suggestions?

    [edit]
    I may have omitted a pertinent detail - I'm developing this on a Windows 8 machine, and it has to work on all current Windows platforms.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    Not sure. There was also a trick to use xml events and update header and lines.
  • ara3nara3n Member Posts: 9,256
    make sure the object is instantiated on the client and not on the server. there is a property on the variable to change that.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • bknoppbknopp Member Posts: 37
    I had a "doh!" moment, but it's working now.

    I had created the wrong kind of object - initially I'd created an IWshShell3 object. I needed to create a WshShell object instead (no leading "I" or trailing "3"). Once I set the variable to the correct object, it worked like a charm.

    I don't suppose there's a way to suppress that "is it okay to use automation?" dialog, is there?
  • mdPartnerNLmdPartnerNL Member Posts: 802
    The warning comes up only once..?
  • bknoppbknopp Member Posts: 37
    I only saw it once, but when I saw it during my local testing I chose "always allow". I'm not sure what happens when other options are chosen.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    once is normal
Sign In or Register to comment.