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)

Automatically creating PO from PR

(0) ShareShare
ReportReport
Posted on by 347

Dear All,

my client wants to use PO & PR Workflow in same time.

 i had created both workflow.

and he need automatically creation of PO from once PR Approved.

So i setup automatic creation of po once PR Approved through purchase policy and batch job, it is working fine but problem is once PR Approved PO Is creating with Approved Status.

if we wants run PO workflow it should be with DRAFT Status.

So Please Help Me to solve this issue.

Thanks,

Regards,

Ashok

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    faheem Ahmed Profile Picture
    450 on at
    RE: Automatically creating PO from PR

    This is default behavior of AX to stop status from getting approve you need a little customization

    Go to \Classes\PurchAutoCreate_PurchReq\endUpdate

    public void endUpdate()

    {

       super();

       // Calculate discount before purchTable is automatically changed to approval status

       if (purchTable.ChangeRequestRequired)

       {

           purchTable.reread();

           if(PurchParameters::find().AutomaticTotalDiscount)

           {

               purchTable.updateFinalDisc();

           }

       }

       //purchTable.autoApproveChangeRequest(); comment this line

    }

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Automatically creating PO from PR

    Hi Faheem,

    Thanks for your reply

    This is working only when we create Manual Purchase Order

    We have done this successfully in manual creation of purchase Order

    While through Batch Job.It is not working.We tried a lot.

    Please Help.

    Regards.

  • faheem Ahmed Profile Picture
    450 on at
    RE: Automatically creating PO from PR

    Can you explain more how you are creating through batch I mean is there any validation of sort or you are just creating PO for all Approved PR

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Automatically creating PO from PR

    Hi Faheem,

    In purchase Requisition in setup policies they have given option as

    Automatically Create Purchase Order

    then in Periodic - Batch Purchase Order Generation  from there Batch Job setup is done

    and After approved status of Purchase Requisition only the batch job runs and purchase order is created and after succesful creation of purchase requisition The status of purchase requisition is changed to Closed Status..which means Purchase Order is created as per my knowledge

    After successful creation of purchase order the status of purchase order is coming as Approval.we want to customize as Draft

    Please Provide me any help.

    Regards.

  • Suggested answer
    faheem Ahmed Profile Picture
    450 on at
    RE: Automatically creating PO from PR

    In that case you need to manually change it back to Draft classes involved are

    PurchReqPurchaseOrderGenerationBatch

    RequisitionReleaseStrategy

    RequisitionPurchaseOrderGeneration

    I think your best bet is to update status \Classes\PurchAutoCreate_PurchReq\createPurchLine

    In this method.

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Automatically creating PO from PR

    Hi Faheem,

    I tried to update status \Classes\PurchAutoCreate_PurchReq\createPurchLine

    But faheem can you please tell me how to update.

    ex-1 = purchtable.documentstate = versioningdocumentstate::draft;

    this is not working

    ex-2 = select forupdate purchtable where purchtable.purchid == purchtable.purchid;

    purchtable.documentstate = versioningdocumentstate::draft;

    purchtable.update();

    I tried in placing even in purchtable methods.

    Not working

    Please help us Faheem.

    Regards

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Automatically creating PO from PR

    Hi Faheem,

    Hope You are fine,

    Please provide me any help regarding Purchase Order Draft Status.

    Waiting For your reply.

    Regards.

  • Muhammad Tauseef Younis Profile Picture
    85 on at
    RE: Automatically creating PO from PR

    Can you please try this in \Classes\PurchAutoCreate_PurchReq\createPurchTable

    Also keep following comment as well

    //purchTable.autoApproveChangeRequest(); comment this line

    I am not able to test it as i have no working purchase requisition setup, just give it a try

  • Suggested answer
    faheem Ahmed Profile Picture
    450 on at
    RE: Automatically creating PO from PR

    AX use document classes to record workflow status I cannot comment here how to change them but this is just a work around.

    write like this for line status in Classes\PurchAutoCreate_PurchReq\createPurchLine

    purchLine.PurchStatus = PurchStatus::Backorder;

    for purchtable

    You can update here also which is not right approach but I can only explain in limited context

    ex-2 = select forupdate purchtable where purchtable.purchid == purchLine.purchid;

    purchtable.documentstate = versioningdocumentstate::draft;

    purchtable.update();

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Automatically creating PO from PR

    Hi Tauseef,

    There is no such piece of code in

    Classes\PurchAutoCreate_PurchReq\createPurchTable

    Only in endUpdate() it is present.but i already commented that

    Please Help.

    Regards

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
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans