@FarhanaM60 Are you seeing this issue without your customizations on the instance?
Hi @FarhanaM60
After updating Curyunitcost in POLine, can you raise FieldUpdated event for Order Total field and check whether this helps to update Order Total properly.
Yes its an issue with Customization
@vivekm - I will check now and let you know
@FarhanaM60 It seems caches are not updating properly with you code.
Can you please share your source code, we can take a look and let you know if we found anything related to this issue.
@Naveen B
protected void POLine_RowUpdated(PXCache cache, PXRowUpdatedEventArgs el)
{
var row = (POLine)el.Row;
if (row == null) return;
POLineExt Ext = row.GetExtension<POLineExt>();
InventoryItem item = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(Base, row.InventoryID);
if (item?.ValMethod == INValMethod.Specific)
{
row.CuryUnitCost = 0;
Base.Transactions.Cache.RaiseFieldUpdated<POLine.curyUnitCost>(row, null);
Base.Transactions.Cache.RaiseFieldUpdated<POLine.curyLineAmt>(row, null);
Base.Transactions.Cache.RaiseFieldUpdated<POLine.curyExtCost>(row, null);
Base.Document.Cache.RaiseFieldUpdated<POOrder.curyOrderTotal>(row, null);
//}
}
//}
}
@FarhanaM60 I have not tested below, but hope this works. Can you please verify
public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
{
protected virtual void POLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
POLine row = e.Row as POLine;
if (row != null)
{
InventoryItem item = InventoryItem.PK.Find(Base, row.InventoryID);
if (item?.ValMethod == INValMethod.Specific)
row.CuryUnitCost = 0m;
}
}
}
@Naveen B -Only when inventory id is selected it is making value 0 other wise if we change order qty or anything else it is bringing value from Stock items screen
Hi @FarhanaM60 Understood. I have verified with below and it is working fine.
Please find the source code below.
public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
{
protected virtual void POLine_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
POLine row = e.Row as POLine;
if (row != null)
{
InventoryItem item = InventoryItem.PK.Find(Base, row.InventoryID);
if (item?.ValMethod == INValMethod.Specific)
row.CuryUnitCost = 0m;
}
}
}
@Naveen B -same code i have written but order total is not calculating properly
Hi @FarhanaM60 Instead of going with RowUpdated event, can you try with below code.
This is working in all scenarios.
protected virtual void POLine_CuryUnitCost_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
POLine row = e.Row as POLine;
if (row != null)
{
InventoryItem item = InventoryItem.PK.Find(Base, row.InventoryID);
if (item != null && item?.ValMethod == INValMethod.Specific && row.CuryUnitCost > 0m)
{
Base.Transactions.Cache.SetValueExt<POLine.curyUnitCost>(row, 0m);
}
}
}
Hope this helps!!
@FarhanaM60 Great :) Thanks for the confirmation.