The following post is used to show, how to change the Purchase order to the "Draft" state. Sometimes to update simple fields it might check for the versioning state of the purchase order and it will through the following error "Changes to the document are only allowed in state Draft because change management is activated". For this case, you can use the following code.
/// <summary>
/// Change the purchase order state to draft
/// </summary>
/// <param name = "_purchTable">Purchase order buffer</param>
protected void changeState(PurchTable _purchTable)
{
if (_purchTable.ChangeRequestRequired && _purchTable.DocumentState >= VersioningDocumentState::Approved)
{
VersioningPurchaseOrder::newPurchaseOrder(_purchTable).createChangeRequest();
}
}
No comments:
Post a Comment