web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

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

(0) ShareShare
ReportReport
Posted on by 1,099

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

I have the same question (0)
  • Martin Dráb Profile Picture
    239,660 Most Valuable Professional on at

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

  • Sridhar Narayanan Profile Picture
    1,099 on at

    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.

  • Verified answer
    Martin Dráb Profile Picture
    239,660 Most Valuable Professional on at

    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
    1,099 on at

    Hi Martin,

    Thank you very much.

    Regards,

    N.Sridhar

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dekion Profile Picture

dekion 4

#2
Virginia99 Profile Picture

Virginia99 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans