Skip to main content
Solved

Last Ordered Date For Stock Items

  • Mar 15, 2021 12:23 PM UTC
  • 8 replies
  • 384 views
  • Translate All

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….

Best answer by Naveen Boga

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!!

View original

8 replies

Gabriel Michaud
Captain II
Forum|alt.badge.img+12

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.

 

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Mar 15, 2021 5:39 PM UTC

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!!

Translate

  • Author
  • Freshman I
  • Mar 16, 2021 6:19 AM UTC

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.

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Answer
  • Mar 16, 2021 6:40 AM UTC

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!!

Translate

  • Author
  • Freshman I
  • Mar 17, 2021 9:43 AM UTC

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.. :)

 

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Mar 17, 2021 9:49 AM UTC

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

Translate

  • Author
  • Freshman I
  • Mar 27, 2021 11:07 AM UTC

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

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Mar 27, 2021 2:43 PM UTC

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.

Translate