Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Cannot run form on non interactive session

(0) ShareShare
ReportReport
Posted on by

Hi all,

i'm tring to run a report during the posting of a ledger journal table to print a proforma invoice for a vendor. In AX 2012 it worked by customizing the post VendVoucher.post() method calling the the report by menuFunction. So in 365 i have extened the VendVoucher this way:

[ExtensionOf(ClassStr(VendVoucher))]
final class PAC001aVendVoucher_Extension
{
    public void post(LedgerVoucher   _ledgerPostingJournal,
                     CustVendTrans   _vendTrans,
                     NoYes           _approval,
                     UnknownNoYes    _euroTriangulation,
                     boolean         _withHoldTaxType,
                     boolean         _useSubLedger)
    {

        ledgerJournalTable  ledgerJournalTable;
        ledgerJournalTrans  ledgerJournalTrans;
        ;

        ttsbegin;

        next post(_ledgerPostingJournal, _vendTrans, _approval, _euroTriangulation, _withHoldTaxType, _useSubLedger);
 
        if (common.TableId == tablenum(LedgerJournalTrans))
        {
            LedgerJournalTrans = common;
            ledgerJournalTable = LedgerJournalTrans.ledgerJournalTable();
        }

        if(ledgerJournalTable.PAC001aPrintProforma)
            this.PAC001aCommissionPrintJournal(vendInvoiceJour);
 
        ttscommit;
    }

    void PAC001aCommissionPrintJournal(vendInvoiceJour _vendInvoiceJour)
    {

        Args args;

        ;
        _vendInvoiceJour.Proforma   = NoYes::Yes;
        args = new Args();
        args.name(identifierStr(PurchInvoiceOriginal));
        args.record(_vendInvoiceJour);
        new menuFunction('PAC001aAgentProformaInvoice', MenuItemType::Output).run(args);
        //new menuFunction('PurchInvoiceOriginal', MenuItemType::Output).run(args);

        throw error(strFmt("%1 %2", "@SYS119253",_vendInvoiceJour.vendName()));

    }

}

where the throw error is needed beacuse i want to rollback the process after the report has printed to screen.

In Ax 365 this gives me the error :

"Stack trace: Cannot run form on non interactive session"

Someone can halp me to print the report and rollback as i can do in ax 2012?

*This post is locked for comments

  • Anton Venter Profile Picture
    20,130 Super User 2025 Season 1 on at
    Cannot run form on non interactive session
    Hello,
     
    Please don't reply to old posts, instead create a new one and give the community as much information as possible about your situation.
  • Ludovico M. Profile Picture
    27 on at
    Cannot run form on non interactive session
    I got the same problem. I have to print a report while posting a product receipt, but everything I tried doesn't work. Anyone got a solution?
  • Community Member Profile Picture
    on at
    RE: Cannot run form on non interactive session

    Got this problem today after cleaning up BP violations. 

    For me the culprit was this method in a class that extended RunBaseBatch.

    public boolean canRunInNewSession()
    {
    return true; //change to false and error is gone
    }

  • Martin Dráb Profile Picture
    234,658 Most Valuable Professional on at
    RE: Cannot run form on non interactive session

    You can't run a dialog in a non-interactive session. As there is no user, nobody can fill values and confirm the dialog. Therefore if it was somehow possible, it would be last thing that the process would do.

  • nec_ronaldy Profile Picture
    10 on at
    RE: Cannot run form on non interactive session

    Is this issue solved?

    Please help to solve.

  • tyhj Profile Picture
    625 on at
    RE: Cannot run form on non interactive session

    I have a custom report to print after product receipt is posted OK, there is a parameter to enable printing, if I printed together with the product receipt, it is printed OK. But if I want to print my custom report alone, then there is error : "Stack trace: Cannot run form on non interactive session"

    When debug, dialogForm.formRun().run(); is giving the error.

    print custom report only: formRun is SysOperationTemplateForm

    print product receipt then custom report: formRun is SrsReportViewerForm

    How can i change my report call to use the correct formRun ?

  • martinarul Profile Picture
    221 on at
    RE: Cannot run form on non interactive session

    Hi Nyonik

      Did you resolve the issue,  I am facing the same problem while opening a report in D365.

    Can you please tell me the solution?

  • Community Member Profile Picture
    on at
    RE: Cannot run form on non interactive session

    As suggested i moved the method from VendVoucher to LedgerJournalTransUpdateVend but i have the same error.

  • Community Member Profile Picture
    on at
    RE: Cannot run form on non interactive session

    I'm sorry but you miss the point: that method is only called when needed and in 6 years of implementation we had 0 problems about that in 3 different version of AX 2009, 2012 2012 R3 in many customer using it. Are you suggesting me that VendVoucher is executed in non interactive session while LedgerJournalCheck post will run in interactive session? If it is so, how can i check it?  So, what i'm asking is how can i check and control in AX 365 if the session is interactive or non interactive.

  • Brandon Wiese Profile Picture
    17,788 on at
    RE: Cannot run form on non interactive session

    I'm sure once you got it working it kept working for you, that's not what I meant by risk.

    What I meant by risk is a departure from best practices or from sound development practices, such that modifications can be broken by hotfixes, patches, upgrades, other developers, or even just circumstances outside your control.  I've seen AX code that broke from Windows Updates related to Internet Explorer.

    In your specific case, you should not launch an interactive menu item from VendVoucher.  That code runs deep inside of many other processes, and you have no control over where or how.  It will run in Batch.  It will run on the server (on AX 2012 anyway).  It will check permissions at a place where they should no longer matter.

    Regardless of my opinion about your implementation, the fact remains that it will not work any longer.  Perhaps you should consider printing your documents in the class responsible for journal posting instead.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Kempeth Profile Picture

Kempeth 4

#1
Andy Adamak Profile Picture

Andy Adamak 4

#1
Community Member Profile Picture

Community Member 4

Featured topics

Product updates

Dynamics 365 release plans