I have a custom DAC to save different Branch prices of an item.
When i try to save the inventory item, I'm getting "Specified cast is not valid" error:
I'm not sure whether one of the Branch attribute is at fault though.
Here is my DAC
using System;
using PX.Data;
using PX.Objects.IN;
using PX.Objects.GL;
namespace SalePriceByBranch
{
[Serializable]
public class INItemPriceByBranch: IBqlTable
{
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Inventory ID")]
[PXParent(typeof(Select<InventoryItem, Where<InventoryItem.inventoryID, Equal<Current<INItemPriceByBranch.inventoryID>>>>))]
[PXDBDefault(typeof(InventoryItem.inventoryID))]
public Int32? InventoryID { get; set; }
public class inventoryID : IBqlField{}
[PXDBInt(IsKey=true)]
[PXUIField(DisplayName = "Branch")]
[PXDefault(0)]
[Branch()]
public Int32? BranchID{ get; set; }
public class branchID : IBqlField{}
[PXDBDecimal(4)]
[PXUIField(DisplayName = "Unit Price")]
[PXDefault(TypeCode.Decimal,"0.0")]
public Decimal? UnitPrice { get; set; }
public class unitPrice : IBqlField{}
}
}
I reckon the error on BranchID is a red herring. Here is the error trace :
Any thoughts ? Thanks for the replies !