2013 - Strange Page/Code Sequence

JDVyskaJDVyska Member Posts: 179
edited 2012-11-15 in NAV Three Tier
So...

Make an Action on a page that does:
PAGE.RUN(PAGE::"Sales Orders");
SLEEP(30000);

You'll wait for 30 seconds, then see a Sales Order Page. Why?

Obviously, this is a pointless example, but I'm working on change in 2013 that requires a page to open, then other actions to happen after (with the page still open, which is why RUNMODAL won't do). Why are Pages opened at the very end, regardless of how it is coded?


Edit: Even trying to 'trick it' through the automation Script Host Model, with a
ScriptHostObject.Run('dynamicsnav:////runpage?page=9305&mode=view');
call doesn't help.
JEREMY VYSKA
CEO, Spare Brained Ideas, Göteborg, Sweden
New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"

Comments

  • Rob_HansenRob_Hansen Member Posts: 296
    I hit a similar challenge in NAV 2009 RTC that involved printing a report to PDF that had only a classic layout. This is different than your scenario, but the workaround might be worth trying. My code structure was:

    //PDF printer automation code here
    REPORT.RUNMODAL(REPORT::"Report to be PDFed");
    //Code here to pick up the PDF and do something with it
    //Endpoint

    The report was not run and the PDF was not created until the "Endpoint" was hit. If I did something that returned control to the user interface, like a CONFIRM prompt after the REPORT.RUNMODAL, it would generate the PDF at that point. I don't know if this will work in your case, but through trial and error I found that if I simply opened and closed a Dialog window, it had the same effect and things worked okay. i.e.:

    //PDF printer automation code here
    REPORT.RUNMODAL(REPORT::"Report to be PDFed");
    Dialog.OPEN;
    Dialog.CLOSE;

    //Code here to pick up the PDF and do something with it
    //Endpoint
  • beranberan Member, Microsoft Employee Posts: 80
    As far as I know:

    The server does not call back to the client if the action does not impact the state of the AL session. The dialog.open may change the state of the AL session and hence it is executed right away.
    Eric Beran
    Software Design Engineer II
    Dynamics NAV Office 365
    Microsoft

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • krikikriki Member, Moderator Posts: 9,112
    PAGE.RUN(PAGE::"Sales Orders");
    SLEEP(30000);
    
    This is normal behaviour. NAV is singlethreaded. So you want to run the page independently from the current object. But the page will only be run when the original object has stopped processing. In your case: AFTER the SLEEP-command.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Rob_HansenRob_Hansen Member Posts: 296
    Sorry...kriki is right. I misread your original post. In my case, I was doing a REPORT.RUNMODAL, but NAV still wouldn't execute it until the end of the code execution (for reports with a classic layout only, running under the RTC). My apologies if I mislead you on my suggestion.
Sign In or Register to comment.