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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

Best way of triggering Purchase Order's version change

(0) ShareShare
ReportReport
Posted on by

Good afternoon, 

Whole day's research on how PO confirmation versions works left me wondering what is the best approach of turning the order to unconfirmed mode, so later it can get confirmed and get a new version? 

I understand that if you change something that changes the purchase agreement, such as order line's quantity or order's payment terms, by default turns the order to unconfirmed state. I see the default code for it, but I'm struggling to follow the logic in case I wanted order to become unconfirmed after I change something, what is not considered as change of an agreement by default. Say, internal/external notes fields from DocuRef table, that are associated with the order and shown in PurchTable form? 

What logic should I follow in this case? 

Thank you! 

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    48,843 User Group Leader on at
    RE: Best way of triggering Purchase Order's version change

    in business world if you change any field which has impact on Price and/or Terms&conditions, it should ask for re-confirmation of PO

    But what happens in AX; after confirmation of PO, if you change anything, it gives you option to re-confirm; you can test this thing by doing a small experiment,

    simply create a PO

    confirm it

    now go to any text field, in lines header anywhere, just put one space, save it.

    AX will give you option to re-confirm order again.

  • Community Member Profile Picture
    on at
    RE: Best way of triggering Purchase Order's version change

    Thank you Sohaib.

    My previous response got removed from this thread for some reason, so this time I'll make it short.

    Not all field changes are triggering re-confirmation. As an example, Header View > Price and discount > Payments > Due date change doesn't, and Header View > Price and discount > Payments > Terms of payment - does. 

    So my question is, where/how do I start this chain of re-confirmation in X++ for custom fields or those not considered as an agreement breakers? So far I've tried methods like below, but with no luck. 

    ttsBegin;
        VersioningPurchaseOrder::newPurchaseOrder(purchTable, true).change(purchTable, purchTable_Orig);
        purchTable.IsModified = NoYes::Yes;
    ttsCommit;
    
  • Sohaib Cheema Profile Picture
    48,843 User Group Leader on at
    RE: Best way of triggering Purchase Order's version change

    I think its totally a manual decision which is needed to be taken by business owners. They are the one who know that on changing of what it should trigger the re-confirmation of PO.

    for you being a technical person, you may create a setup, where there can be selection of fields from PurchTable and PurchLine. By selection of any field(s) on this setup, it would specify that on changing of data on theses fields, system should trigger/ask for re-confirmation of PO.

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at
    RE: Best way of triggering Purchase Order's version change

    I'm not sure if this is what you are looking for, but you can try the following (Taken from purchLineType.update() )

    purchLine.updateWorkflowState(TradeWorkflowState::NotSubmitted);

    purchLine.purchTable(true).updateFromPurchLines(false);

  • Community Member Profile Picture
    on at
    RE: Best way of triggering Purchase Order's version change

    Thank you, Jonathan. Yes, that's something similar to what I'm looking for, but unfortunately your solution didn't worked, even though it didn't returned any errors.  

    So I'm trying these little code snippets that I find in PurchLine and PurchTable objects, but nothing seems to work, and I fail to see a common code that is being shared between those elements, that are breaking the agreement.

    As AX documentation puts it "The purchase order is the most complex use of the versioning pattern in Microsoft Dynamics AX 2012.". 

    I'm hoping to find that "single line solution" somewhere :) 

  • Jonathan  Halland Profile Picture
    11,310 on at
    RE: Best way of triggering Purchase Order's version change

    Hi

    What happens when you execute my or other solutions? What are you expecting to occur?

  • Community Member Profile Picture
    on at
    RE: Best way of triggering Purchase Order's version change

    Putting it simple - after my custom field in PO form gets modified, I expect Purchase > Confirm button to become active, so after clicking on it a new version of Purchase order confirmation will be generated. 

    When I run your solution in modified() method of my custom field, the purchLine object is filled up with the information of the first line of the order. I haven't drilled down more, I'm afraid. 

    Thank you!

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Best way of triggering Purchase Order's version change

    I think I may have found it!

    purchTable.type().updateDistribution();
    purchTable_ds.reread();
    purchTable_ds.refresh();
    
  • Community Member Profile Picture
    on at
    RE: Best way of triggering Purchase Order's version change

    Hi Donatas, Did you manage to find a better way of doing this?

  • Suggested answer
    Asim Saeed Profile Picture
    575 on at
    RE: Best way of triggering Purchase Order's version change

    Hey Donatas,

    I have also came across some what the same issue, and what i did to cater the scenario is;

    I created a new class extends from VersioningPurchaseOrder and Added a added a method from parent,

    which sets the purchTable Modified field to TRUE to be picked for COnfiramation.

    public void markModified()
    {
    super();
    purchTable.IsModified = NoYes::Yes;
    }

    and finally I initialized the class and called 'markModified' method after super call.(You can do it in field modified as well) . In my case i did in clicked method.

    Let me know if it worked for you as well.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#1
Community Member Profile Picture

Community Member 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans