A problem with a window

jpelahojpelaho Member Posts: 14
Hello

I have a problem. When I carry out a transaction and that an error occurs, the window of the type "window" that I open at the beginning does not close when I close the error message.

Thanks in advance.
Jp.

Answers

  • kinekine Member Posts: 12,562
    From where is the form called? Can you describe the trigger workflow?
    (something like " from OnPush I call Codeunit.run and within it I call FORM.RUN and after that....)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jpelahojpelaho Member Posts: 14
    from OnPush I call Codeunit.run

    At the beginning of my Codeunit I call a window to follow the evolution of the treatments like that :
    IF GUIALLOWED THEN
       Window.OPEN(
           '#1###############################################\\' +
            Text006);
    

    Then after several treatments, I close the window at the end of my code unit
    IF GUIALLOWED THEN
      Window.CLOSE;
    

    If an error occurs and when i close the error message, the first window that i open to follow the transaction does not close.
    Jp.
  • kinekine Member Posts: 12,562
    Are you calling the codeunit in IF-THEN (if codeunit.run then) statement or
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jpelahojpelaho Member Posts: 14
    No. That is all the code on the onPush trigger
    IF GUIALLOWED THEN
        IF NOT CONFIRM(Text000,FALSE) THEN
          EXIT;
    
      AdjCBPost.RUN(Rec);
    

    AdjCBPost is my codeunit.
    Jp.
  • kinekine Member Posts: 12,562
    Yes, it is simple - because the Window variable you are using is global in the Codeunit, and the codeunit is runned through codeunit global variable, after the error the Window variable nor codeunit is cleared. You need to move the variable into some scope, which is not longer valid after the error. For example using local variable if possible, running the codeunit through "CODEUNIT.RUN(CODEUNIT::"xxx",Record)" or clearing the codeunit in some point... (Clear(AdjCBPost)).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jpelahojpelaho Member Posts: 14
    Thank you for your help.
    Jp.
  • kinekine Member Posts: 12,562
    You are welcome...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.