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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Activate Change Management on POs Through X++

(0) ShareShare
ReportReport
Posted on by 89

Hi, 

I had a requirement to change a field on a PO during the time of confirmation, however, I had to toggle change management to "No' in order to update the field. I then want to change 'changerequestRequired' back to yes after I update the field, but I am getting an error "Changes to the document are only allowed in state Draft, because change management is activated". This is failing on the second update() line because change management has been set back to yes in the code, but won't update on the SQL table. After the code below, the field changerequestrequired is still set to No, when I desire it to be set to Yes. 

Any help is appreciated.

ttsbegin;
purchTableSelected.ChangeRequestRequired = NoYes::No;
purchTableSelected.CE_ApplyAttachment = NoYes::No;
purchTableSelected.update();
ttscommit;

ttsbegin;
purchTableSelected.selectForUpdate(true);
purchTableSelected.ChangeRequestRequired = NoYes::Yes;
purchTableSelected.update();
ttscommit;

next clicked();

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

    Wouldn't it be a solution if you skip business logic in update() by calling doUpdate() instead or using PurchTableSkipBusinessLogicContext?

    using (var purchTableSkipBusinessLogicContext = PurchTableSkipBusinessLogicContext::construct())
    {
    	purchTableSkipBusinessLogicContext.parmSkipUpdate(true);
    	purchTableSelected.CE_ApplyAttachment = NoYes::No;
    	purchTableSelected.update();
    }

    By the way, I see you've put your logic into a clicked(), which isn't a good idea. Business logic doesn't belong to form control methods and it's definititely not where order confirmation posting is done. Look at PurchPurchOrderJournalPost class 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans