Options

Immediately disable a Page component

jurjur Member Posts: 8
edited 2010-08-10 in NAV Three Tier
I'm trying to disable a Field of a Page for duration of another process. I've set the Enabled property to a global Boolean variable (which also has property IncludeInDataset = Yes). Now when I set this property to FALSE, the Field doesn't immediately get disabled. It seems like this property is only evaluated when Page is idle (after all of the functions exit). But I need to set it to FALSE, do some processing and set it back to TRUE again in the same function. I've tried CurrPage.UPDATE - no luck. ](*,)

Comments

  • Options
    kinekine Member Posts: 12,562
    This is known "problem". But one question...
    But I need to set it to FALSE, do some processing and set it back to TRUE again in the same function

    If I understand it correctly, you run some process and you want to set the property during this process to false and back. Isn't it useless because user will not be able to do anything during the process is running even without this?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jurjur Member Posts: 8
    Thanks for the response. OK, here's what I'm doing:

    I have a C/AL function, which uses a COM object to do some processing. That COM object pops up a dialog box, which I'd like to be modal, but couldn't find a way, as getting the handle of the active RTC window is not easy and/or reliable. So the dialog shows up and the user can do anything with the UI. That's why I chose to disable the page, so the user can't touch the UI and call more processes with dialogs. Any ideas? :roll:
  • Options
    kinekine Member Posts: 12,562
    Than you need modal the call of the automation... it should not be so hard...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jurjur Member Posts: 8
    kine wrote:
    Than you need modal the call of the automation... it should not be so hard...
    Modal call of the automation? How do you do THAT? I thought the call should be synchronous and freeze NAV, but it doesn't. This is really getting on my nerves... #-o
  • Options
    kinekine Member Posts: 12,562
    All depends on how the dialog is started in the Automation. If the call of the function in automation returns before the window is closed, than the problems i there. In most cases the call of the function should end after the process in the function is finished. If it is some automation you can modify, look there... Even the MessageBox or Window in C# could be displayed as modal or non-modal.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jurjur Member Posts: 8
    I AM showing a modal dialog in the automation object... And the automation function only returns after all the stuff is done. But the user is free to do everything he likes in the NAV UI. Oh, by the way, I should probably mention, that the C/AL function I'm calling the automation object from is OnControlAddIn. It's an add-in, that does drag'n'drop and then calls OnControlAddIn asynchronously. Then OnControlAddIn calls the automation object to do the processing.
  • Options
    kinekine Member Posts: 12,562
    Ah, that's the problem. The addin process is not blocking the standard NAV processes. It is running in separate thread or something, because it is not considered to run some "blocking business logic". But now I understand your situation... and I have no solution for you right now...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jurjur Member Posts: 8
    All right, thanks for replying anyway. I'm currently trying to use C/SIDE Utilities to get the active window handle, pass it to my automation object and then use it in Form.ShowDialog (.NET). I hope it works. [-o<

    Edit:
    Passing the window handle didn't work... The execution is completely detached from NAV. I can even close RTC and I still have the automation running, the process completes without RTC. I'll have to come up with some complex workaround in this case...
  • Options
    jurjur Member Posts: 8
    OK so I'm coming back with a solution in case anyone gets into the same trap...

    I'm calling ControlAddIn separately before the actual processing with an Index, indicating to disable the UI. Then the next call is the actual processing with enabling of UI at the end of the function. Pretty ugly from programmer's perspective (as many of NAV solutions :)), but it works and is simple.

    This definitely was a lesson for me. Thanks, kine, for the input.
  • Options
    jurjur Member Posts: 8
    I'm bringing this up again, as we're experiencing some errors and instability with the approach that I took (last post).

    Sometimes I get this error: "An internal error has occured. Multiple concurrent calls have been issued to the server from this client."
    I think this is because of two subsequent ControlAddin calls. The behaviour is really strange, looks like there are lots of problems with the synchronization between the Add-in and NAV... :-k
    I've also seen some other errors and odd behaviour in area that's supposed to be really simple, synchronous and shouldn't give results that I'm getting...

    Any suggestions? Tips of add-in developing, practices? Information sources about add-in and NAV communication and internals? Any help appreciated.
  • Options
    kinekine Member Posts: 12,562
    May be the problem is, when you call the addin function from within the trigger of the addin. Try to fire the NAV event within the addin in new thread... it is just a guess...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.