Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / Sales order hold issue...
Finance forum

Sales order hold issue via X++

(0) ShareShare
ReportReport
Posted on by 6,603

Hello there,

I've got the following code below to add a hold onto a sales order. 

ttsBegin;
MCRHoldCodeTrans holdCodeTrans;
holdCodeTrans.InventRefId = _salesId;
holdCodeTrans.MCRHoldCode = 'Pricing';
holdCodeTrans.insert();
ttsCommit;

I've added this code to an extension class in WhsWarehouseRelease. Something must be off as I'm not seeing the hold applied. What I've tried is running the code in a Runnable class and it appears to work there. I may be missing something?

Thank you!

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Sales order hold issue via X++

    ttsabort will roll back anything that was done inside that transaction. You can't do anything about that.

  • bankk Profile Picture
    bankk 6,603 on at
    RE: Sales order hold issue via X++

    Hello,

    I discovered a method in the stack call with was calling ttsabort under a specific condition. When I created the hold record I'm in that condition. Is there a way to force the insert regardless of the ttsabort call? Thank you.

  • bankk Profile Picture
    bankk 6,603 on at
    RE: Sales order hold issue via X++

    I used CoC, and yes, I did run the debugger. The method is being called, I even see the RecId when the object is built but I can't find the record in the MCRHoldCodeTrans table nor can I see it on the Sales order's "Order hold". I just tried a full model compile and still no luck.

  • Sukrut Parab Profile Picture
    Sukrut Parab 71,673 Moderator on at
    RE: Sales order hold issue via X++

    Did you implement this using event handler or using COC ?  Did you check in the debugger , if that method is being called when you execute your process ?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans