Skip to main content

Hi,

I have done Custom in Purchase Order Screen
In POLine level am trying to update Curyunitcost according to InventoryID -(Stock Item screen-Valuation Method-Specific)equal to 0

it is updating but in header order total is updating with the price cost which is defined in stock items screen..

From Where it is getting updating am not knowing..

Please Suggest me with the Proper solution

 

@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


@vivekm -its not working 

 


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


@Naveen B -

Thanks Its working


@FarhanaM60  Great :)  Thanks for the confirmation.


Reply