Activate Change Management on POs Through X++

 I had a requirement to update a field on a Purchase Order (PO) during the confirmation process. To make this change, I temporarily set Change Management to "No". After updating the field, I attempted to set ChangeRequestRequired back to "Yes".

However, I encountered the following error:

"Changes to the document are only allowed in the state Draft, because change management is activated."

The error occurs on the second update() call because the system considers Change Management as already enabled, even though the flag hasn’t been persisted to the database yet. As a result, the update is blocked due to the PO no longer being in the Draft state.

using (var purchTableSkipBusinessLogicContext = PurchTableSkipBusinessLogicContext::construct())

{

purchTableSkipBusinessLogicContext.parmSkipUpdate(true);

purchTableSelected.CE_ApplyAttachment = NoYes::No;

purchTableSelected.update();

}

Comments

Popular posts from this blog

Update Deployment Failed due to Missing MpProvider Module

How to Resolve DVT Script Issues When Applying Quality Updates in LCS for D365FO

How to remove deployed model in Tier2 environment in D365FO