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 :
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
    240,061 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Subra Profile Picture

Subra 373

#3
Martin Dráb Profile Picture

Martin Dráb 251 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans