Solved

Last Ordered Date For Stock Items

  • 15 March 2021
  • 8 replies
  • 262 views

Helo,

     Im a newbie to acumatica. I want to add last ordered date field for each stock item. So,whenever a new order arrives i want to update last ordered date of that ordered item. How could i do that? please reply asap….

icon

Best answer by Naveen Boga 16 March 2021, 07:40

View original

8 replies

Userlevel 7
Badge +10

Hi @sandy95,

Where do you want to see the last ordered date? Also, are you talking about a Sales Order or a Purchase Order? It sounds like you’re talking about Sales Order from a customer, but just want to be sure.

 

Userlevel 7
Badge +17

Hi @sandy95,

I’m assuming that below is your requirement.

In the Stock Item screen, you have added a new customization field and you want to show the Last Ordered Date of that SKU in that field.  

 

If this is your requirement, then yes, it more of customization, and below are the steps.

 

You need to extend the SOOrderEntry graph and add a logic to update the “LastOrderedDate” in the Stock Item screen of the 1st Save of the Sales Order (Persist Delegate).

 

Hope this helps!!

Hi @sandy95,

I’m assuming that below is your requirement.

In the Stock Item screen, you have added a new customization field and you want to show the Last Ordered Date of that SKU in that field.  

 

If this is your requirement, then yes, it more of customization, and below are the steps.

 

You need to extend the SOOrderEntry graph and add a logic to update the “LastOrderedDate” in the Stock Item screen of the 1st Save of the Sales Order (Persist Delegate).

 

Hope this helps!!

 

hi,

Yes exactly i want the way you defined. I already added LastOrderedDate field in Stock Item Screen. And about to extend SOOrderEntry graph but didn’t understand how to save that field . Please Reply. Thanks in advance.

Userlevel 7
Badge +17

Hi @sandy95 ,

 

I wrote a sample example code just now, where I’m updating LastOrderedDate in the Stock Items screen for the particular SKUs.

Please modify according to your DAC field names.

 public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{

public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate del)
{

#region Check Del
try
{
if (Base.Document.Current != null)
{
if (Base.Document.Cache != null && Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
{
InventoryItemMaint itemMaint = PXGraph.CreateInstance<InventoryItemMaint>();

foreach (SOLine objSOLine in Base.Transactions.Select())
{
InventoryItem objInventoryItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, objSOLine.InventoryID);
if (objInventoryItem != null)
{
InventoryItemExt itemExt = objInventoryItem.GetExtension<InventoryItemExt>();
itemExt.LastOrderedDate = Base.Document.Current?.OrderDate;
itemMaint.Item.Cache.Update(objInventoryItem);
}
}
itemMaint.Actions.PressSave();
}

del();
}
}
catch (Exception ex)
{
throw new PXException(ex.Message);
}
}
}

 

Hope this helps!!

Hi @sandy95 ,

 

I wrote a sample example code just now, where I’m updating LastOrderedDate in the Stock Items screen for the particular SKUs.

Please modify according to your DAC field names.

 public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{

public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate del)
{

#region Check Del
try
{
if (Base.Document.Current != null)
{
if (Base.Document.Cache != null && Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
{
InventoryItemMaint itemMaint = PXGraph.CreateInstance<InventoryItemMaint>();

foreach (SOLine objSOLine in Base.Transactions.Select())
{
InventoryItem objInventoryItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, objSOLine.InventoryID);
if (objInventoryItem != null)
{
InventoryItemExt itemExt = objInventoryItem.GetExtension<InventoryItemExt>();
itemExt.LastOrderedDate = Base.Document.Current?.OrderDate;
itemMaint.Item.Cache.Update(objInventoryItem);
}
}
itemMaint.Actions.PressSave();
}

del();
}
}
catch (Exception ex)
{
throw new PXException(ex.Message);
}
}
}

 

Hope this helps!!

 


Thanks @Naveen B ,

       It works.. :)

 

Userlevel 7
Badge +17

@sandy95 That’s great :) Now, I hope you clear with the cache updates.

How to update all existing orders last updated date for stock items?

Userlevel 7
Badge +17

Create an updated SQL script to update the LastOrderDate in the Stock Items screen. This is a one-time activity and for the new orders, your customization will take care of.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved