Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Error: BOX API can't be used from non-interactive sessions.

Posted on by 1,025

Hi Experts,

I am trying to create and post statements through x++ code.

Statement got created and it has updated 'Statement number' in  RetailTransactionTable & RetailTransactionSalesTrans

Also all values are updated properly in RetailStatementTable.

However, the below code which is used to post statements is throwing an error "BOX API can't be used from non-interactive sessions"

RetailStoreOrderSynchronizer::CreateStoreSalesorders (statementTable.statementId, true);

The above line is the replica of native code which posts statements used in batch and also while posting statements manually.

Am I missing any of the setups etc. 

Thanks.

N.Sridhar

*This post is locked for comments

  • Sridhar Narayanan Profile Picture
    Sridhar Narayanan 1,025 on at
    RE: Error: BOX API can't be used from non-interactive sessions.

    Hi Martin,

    Thank you very much.

    Regards,

    N.Sridhar

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,056 Most Valuable Professional on at
    RE: Error: BOX API can't be used from non-interactive sessions.

    I see, it's in run() method of RetailStatementPost class.

    Now you know why this happens. I see a few things your can do about it:

    • Extract the logic you want from run() to a separate method (without the logic you don't want).
    • Claim that it's a bug and ask Microsoft to fix it.
    • Run your logic in batch even if it's not your preference.
    • Hack isInBatch() and let it return true in this case even if it's not in batch (which may have unexpected consequences).
  • Sridhar Narayanan Profile Picture
    Sridhar Narayanan 1,025 on at
    RE: Error: BOX API can't be used from non-interactive sessions.

    Hi Martin,

    Below piece of code in RetailStatementPost is causing this error

           if (!this.isInBatch())

           {

               if (operationProgress)

               {

                   operationprogress.reset();

               }

               if (callerObject)

               {

                   callerObject.activate(true);

               }

               Box::info("@RET4164");

           }

    In my case, we are not using either UI or running a batch to create and post statement. So by default system is considering that Box::info()

    is getting executed from UI. I have either overlay of extend this class and respective method to fix the error.

  • Martin Dráb Profile Picture
    Martin Dráb 230,056 Most Valuable Professional on at
    RE: Error: BOX API can't be used from non-interactive sessions.

    Can you find out which line of code is throwing this error?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans