Skip to main content
Question

Stockitem(IN202500) screen Price/cost tab added CurrentCost Filed Not Save in database

  • Jan 8, 2024 2:27 PM UTC
  • 4 replies
  • 146 views
  • Translate All

Forum|alt.badge.img

How to save currentCost filed in Database ?

This CurrentCost Filed is custom filed

/* DAC */

namespace PX.Objects.IN
{
public class INItemCostExt : PXCacheExtension<PX.Objects.IN.INItemCost>
{
public static bool IsActive() => true;
#region UsrCurrentCost
[PXDBPriceCost(BqlField = typeof(INItemCostExt.usrCurrentCost))]
[PXUIField(DisplayName = "Current Cost")]
[CurySymbol]
public virtual Decimal? UsrCurrentCost { get; set; }
public abstract class usrCurrentCost : PX.Data.BQL.BqlDecimal.Field<usrCurrentCost> { }
#endregion
}
}

/* InventoryItemMaint_Extension */ Bussiness Logic
;

namespace PX.Objects.IN
{
public class InventoryItemMaint_Extension : PXGraphExtension<PX.Objects.IN.InventoryItemMaint>
{
public static bool IsActive() => true;
#region Event Handlers
protected void INItemCost_RowInserted(PXCache cache, PXRowInsertedEventArgs e, PXRowInserted InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
INItemCost row = (INItemCost)e.Row;
INItemCostExt itemCostExt = row.GetExtension<INItemCostExt>();
}

protected void INItemCost_RowPersisted(PXCache cache, PXRowPersistedEventArgs e, PXRowPersisted InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
INItemCost row = (INItemCost)e.Row;
INItemCost INItemCost = (INItemCost)Base.ItemCosts.Cache.Current;
INItemCostExt itemCostExtBase = INItemCost.GetExtension<INItemCostExt>();
}

protected void INItemCost_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
INItemCost row = (INItemCost)e.Row;
INItemCostExt itemCostExt = row.GetExtension<INItemCostExt>();
INItemCost INItemCost = (INItemCost)Base.ItemCosts.Cache.Current;
INItemCostExt itemCostExtBase = INItemCost.GetExtension<INItemCostExt>();

}
#endregion
}
}

Thank You..

4 replies

Forum|alt.badge.img
  • Varsity I
  • Jan 8, 2024 7:07 PM UTC

Try the RowInserting, RowPersisting, and RowUpdating event handlers.  Those are where you can make changes to the data while it is being saved.

 

Translate

Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • Jan 8, 2024 7:09 PM UTC

Try the RowInserting, RowPersisting, and RowUpdating event handlers.  Those are where you can make changes to the data while it is being saved.

 

There are Event not Working to save Datebase

Translate

Forum|alt.badge.img+3
  • Jr Varsity III
  • Jan 11, 2024 1:22 PM UTC

Try with PXDatabase.Update.

Translate

andriikravetskyi35
Jr Varsity I
Forum|alt.badge.img+1

@Rajginoya 

Try to remove BqlField = typeof(INItemCostExt.usrCurrentCost) from your code, this parameter for PXProjectionAttribute and return null on Set

Translate