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….
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
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!!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.