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 :
Finance | Project Operations, Human Resources, ...
Answered

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

(0) ShareShare
ReportReport
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.

I have the same question (0)
  • pam86 Profile Picture
    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
    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
    23,093 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
    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
    23,093 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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,258

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 949 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 631 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans