Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Being able to Edit information within a purchase order while not in "Draft" form

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

I'm attempting to try an push an update by running a job to the OverDeliveryPct field within the PurchLine Table.  I know normally you can only update fields that are in Draft format, but I was wondering how I could update all fields without having to worry whether or not it is in draft, in review, approved, confirmed, etc.?

My error I receive is "Changes to the document are only allowed in state Draft, because change management is activated."  I currently have change management turned off in the section Procurement and Sourcing > Setup > Procurement and sourcing parameters > General > Change management for purchase orders > unchecked box for Activate Change Management.

Is there another place Change Management is activated that needs to be deactivated? or is there something else that I am overlooking?

Thanks,

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Being able to Edit information within a purchase order while not in "Draft" form

    Thanks for sharing your code. We are in a slightly different situation. We need to populate the over delivery and under delivery fields in a PO with certain numbers (100 and 15) upon auto creation of a PO from an approved REQ. I'm not an AX developer myself and I have someone who is doing this coding for us but I don't think this person is on the right path.

  • Suggested answer
    syed baber Profile Picture
    syed baber 11,627 on at
    RE: Being able to Edit information within a purchase order while not in "Draft" form

    Hi Farokh,

    I wrote the code for one of my client to update inventory dimension and delivery date for PO using doUpdate method when change management is activated. I used the dialog form to take input from user and then updated the PO with those values.

    Below is the code:

    public static void updateInventDimAndDeliveryDateForPO(

       PurchTable          _purchTable,

       InventSiteId        _inventSiteId,

       InventLocationId    _inventLocationId,

       DlvDate             _deliveryDate)

    {

       PurchLine           purchLine;

       InventDim           inventDim;

       InventTrans         inventTrans;

       InventTransOrigin   inventTransOrigin;

       ttsBegin;

       if (_inventLocationId || _inventSiteId || _deliveryDate)

       {

           _purchTable.selectForUpdate(true);

           _purchTable.InventLocationId = _inventLocationId ? _inventLocationId : _purchTable.InventLocationId;

           _purchTable.InventSiteId     = _inventSiteId ? _inventSiteId : _purchTable.InventSiteId;

           _purchTable.DeliveryDate     = _deliveryDate ? _deliveryDate : _purchTable.DeliveryDate;

           // Update delivery address based on Site or Warehouse selected on the form.

           _purchTable.setAddressFromInventSiteId(_inventSiteId);

           _purchTable.setAddressFromInventLocationId(_inventLocationId);

           _purchTable.doUpdate();

       }

       // Update all purchase order lines associated with this purchase order header.

       while select forUpdate purchLine

           where purchLine.PurchId == _purchTable.PurchId

       {

           if (_inventLocationId || _inventSiteId)

           {

               // Find the inventory storage dimension for purchase order line record.

               inventDim = purchLine.inventDim();

               inventTransOrigin = InventTransOrigin::findByInventTransId(purchLine.InventTransId);

               // Find Inventory transaction record related to this purchase order with Status Ordered.

               select forUpdate * from inventTrans

                   where inventTrans.InventTransOrigin == inventTransOrigin.RecId &&

                       inventTrans.inventDimId         == purchLine.InventDimId &&

                       inventTrans.StatusReceipt       == StatusReceipt::Ordered;

               // Update the inventory dimensions with the new dimensions if specified in the dialog form.

               inventDim.InventLocationId = _inventLocationId;

               inventDim.InventSiteId     = _inventSiteId;

               // Find the inventory dimension Id based on the value specified on the drop dialog form.

               inventDim = InventDim::findOrCreate(inventDim);

               // If inventory transactions exist for this PO with status 'Ordered'.

               if (inventTrans.RecId)

               {

                   // Update purchase order line with new Inventory dimension Id.

                   purchLine.InventDimId = inventDim.inventDimId;

               // Update the inventory transaction record with new inventory dimensions.

                   inventTrans.inventDimId = purchLine.InventDimId;

                   inventTrans.doUpdate();

               }

           }

           if (_purchTable.DeliveryDate)

           {

               purchLine.DeliveryDate = _purchTable.DeliveryDate;

           }

           purchLine.doUpdate();

       }

       ttsCommit;

    }

    Please let me know if you have further queries.

    Thanks,

    Baber.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Being able to Edit information within a purchase order while not in "Draft" form

    Ranes, is it possible that you share your code with me. We're trying to use doupdate to populate the over\under delivery fields in the PO but we are not succeeding. Any tips would be much appreciated.

    Thanks!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Being able to Edit information within a purchase order while not in "Draft" form

    The doUpdate as opposed to update was exactly what I was looking for.  I greatly appreciate the help!

    Ranes

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,965 Super User 2025 Season 1 on at
    RE: Being able to Edit information within a purchase order while not in "Draft" form

    Hi Ranes,

    There is indeed a pain when you want to update some fields which are internal use only like the Allowed overdelivery.

    As Nitesh said: Once the change management is active for a purchase order, it remains active.

    You could consider a customization to exclude some fields for editing or create a new form which can be called from the purchase order detail lines to update some fields where AX will do the doupdate command.

    Note that AX has the ability to view differences between confirmed versions of the PO. This will not work on these fields anymore as they are changed in a "inregular way".

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Being able to Edit information within a purchase order while not in "Draft" form

    Change Management is activated and deactivated from the same place which you have pointed out.

    Procurement and Sourcing > Setup > Procurement and sourcing parameters > General > Change management for purchase orders > unchecked box for Activate Change Management

    but once a PO is create while Change Management is active, change management remain enforced for those PO even though parameter get unchecked.

    If you want to update the some of the field by running a job, then I suggest you to do it by using

    PurchTable.doUpdate() in place of PurchTable.update()

    Please verify and update us with your findings.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,817 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans