Skip to main content

Notifications

Microsoft Dynamics AX forum
Answered

Assign same sales order number to a purchase order number when using direct delivery on sales line

Posted on by 45

Hi,

I have a requirement where I need to assign the same sales order number to the PO number [+ _SalesLineNumber] during the automatic creation of a purchase order when using direct delivery/drop-shipping. For example, if SO number is SO12345 and sales line 01 has direct delivery then create PO number as SO12345_01 and so on.  I have used the debug mode on the PurchAutocreate [SetPurchTable method] class which generates the PO number and I found that I can use something on the below method of the NumberSeq class. I tried a static number which did work. 

 2020_2D00_05_2D00_12-11_5F00_26_5F00_22_2D00_Window.jpg

I have changed the number sequence for POs to allow users to modify to the upper or lower number which provides the flexibility to change the PO number. 

I just want to confirm is it the right way to fulfil the requirement or is there any easy/another way!! Also, If you can provide examples of how can I add a reference to the given SALES ORDER number and LINE number if I have to use the above process.

Thank you in advance.

  • pam86 Profile Picture
    pam86 45 on at
    RE: Assign same sales order number to a purchase order number when using direct delivery on sales line

    Actually I got it working now. Instead of using PurchAutoCreate_SalesLine, I used PurchAutoCreate_Sales class > method new and add my logic after it initiates the salestable.

  • pam86 Profile Picture
    pam86 45 on at
    RE: Assign same sales order number to a purchase order number when using direct delivery on sales line

    Sorry for the late reply, I do see a new method under the PurchAutoCreate_SalesLine class. However, When I debug this class, it is not even used during the automatic PO creation when using direct delivery. So how can I use to generate value for myPurchId?

    This is what I have tried:

    PurchAutoCreate class > SetPurchTable:

       if (myPurchId != '') //Customized process

       {

           tmpPurchId = myPurchId;

       }

       else //Standard Process

       {    

           num = NumberSeq::newGetNum(PurchParameters::numRefPurchId());

           tmpPurchId = num.num();  

       }

  • Suggested answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Assign same sales order number to a purchase order number when using direct delivery on sales line

    Hi Pam86,

    New is default constructor for every class and it's already there, but in some cases you need to override it. In your case, it should be already overridden, but it depends on AX version. Do you see method new in PurchAutoCreate_SalesLine class?

    docs.microsoft.com/.../best-practices-for-new-and-static-new-methods

  • pam86 Profile Picture
    pam86 45 on at
    RE: Assign same sales order number to a purchase order number when using direct delivery on sales line

    Thank you Sergei for instant reply.

    The PurchAutoCreate_SalesLine.new method, is it something already there or should I create it in PurchAutoCreate class?

  • Verified answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Assign same sales order number to a purchase order number when using direct delivery on sales line

    Hi pam86,

    I do not recommend touching NumberSeq class, as it's used in many places and there is a risk to break everything in the system.

    In your case, you can add a global variable to PurchAutoCreate class (PurchId myPurchId) and generate value to it in PurchAutoCreate_SalesLine.new method based on SalesLine information. In PurchAutoCreate.SetPurchTable you can check if your variable is not empty then assign a value from it to tmpPurchId variable and if it's empty populate tmpPurchId as in standard.

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

News and Announcements

Give Back to the Community this Month

Quick Links

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,802 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,133 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,154

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans