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

Announcements

No record found.

News and Announcements icon
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)
  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    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.

  • pam86 Profile Picture
    45 on at

    Thank you Sergei for instant reply.

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

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    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

    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();  

       }

  • pam86 Profile Picture
    45 on at

    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.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 576 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 366

#3
Adis Profile Picture

Adis 256 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans