Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Calling Action MenuItem: PurchCancel from X++

(0) ShareShare
ReportReport
Posted on by 674

Hi All,

I am calling an action menu item, PurchCancel from my own RunBaseBatch class as follows. 

Args args = new Args();
args.record(purchLine.purchTable());
args.parmEnum(NoYes::Yes);
args.caller(this);
new MenuFunction(menuitemActionStr(PurchCancel), MenuItemType::Action).run(args);

Then I get the following prompt because of the purchCancel.prompt() code in PurchCancel.mainOnServer method.

protected static void mainOnServer(PurchTable _purchTable)
{
    PurchCancel purchCancel = PurchCancel::construct();
    purchCancel.parmPurchTable(_purchTable);

    if (purchCancel.prompt())
    {
        purchCancel.runOperation();
    }
}

pastedimage1618856271336v1.png

Then if I click OK, I get an error saying that An unbalanced X TTSBEGIN/TTSCOMMIT pair has been detected... 

pastedimage1618856395616v2.png

1)how can I avoid this prompt() and 2) also solve this unbalanced X TTSBEGIN/TTSCOMMIT Pair issue?

Thank you. 

  • Verified answer
    Martin Dráb Profile Picture
    232,858 Most Valuable Professional on at
    RE: Calling Action MenuItem: PurchCancel from X++

    I guess that you're trying to open the form from inside the database transaction. This is wrong and the system prevents serious consequences by aborting the transaction.

    I remember a company whose Axapta 3.0 was completely blocked from time to time. The cause was a dialog opened from a transaction (which wasn't rolled back in this version), which somebody sometimes left open and went for lunch or so. The transaction held a lock on InventSum table, preventing other users to do anything involving inventory...

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,060 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,858 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans