Announcements
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.
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.
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.
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();
}
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
Thank you Sergei for instant reply.
The PurchAutoCreate_SalesLine.new method, is it something already there or should I create it in PurchAutoCreate class?
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,802 Super User 2024 Season 2
Martin Dráb 229,133 Most Valuable Professional
nmaenpaa 101,154