我创建了一个新的自定义表,以及一个新屏幕(FormView(来输入数据。我创建了一个通用查询以导航到新的输入屏幕。 使用新输入屏幕输入并保存新表中的第一条记录后,"通用查询"屏幕在其中一列上引发转换错误。这一切都应该非常快速和容易,但我似乎无法绕过铸造错误。
新的表结构:
CREATE TABLE [dbo].[DPItemRebate](
[CompanyID] [int] NOT NULL,
[VendorID] [int] NOT NULL,
[CustomerID] [int] NOT NULL,
[InventoryID] [int] NOT NULL,
[RebateAmt] [decimal](19, 4) NOT NULL,
CONSTRAINT [PK_DPItemRebate] PRIMARY KEY CLUSTERED
([CompanyID] ASC, [VendorID] ASC, [CustomerID] ASC, [InventoryID] ASC)...
数字转换器:
[Serializable]
public class DPItemRebate : IBqlTable
{
#region VendorID
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Vendor")]
[Vendor(typeof(Search<BAccountR.bAccountID,
Where<BAccountR.type, Equal<BAccountType.companyType>,
Or<Vendor.type, NotEqual<BAccountType.employeeType>>>>),
Visibility = PXUIVisibility.SelectorVisible, CacheGlobal = true,
Filterable = true)]
[PXRestrictor(typeof(Where<Vendor.status, IsNull,
Or<Vendor.status, Equal<BAccount.status.active>,
Or<Vendor.status, Equal<BAccount.status.oneTime>>>>),
PX.Objects.AP.Messages.VendorIsInStatus, typeof(Vendor.status))]
public virtual int? VendorID { get; set; }
public abstract class vendorID : IBqlField { }
#endregion
#region CustomerID
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Customer")]
[CustomerActive(typeof(Search<BAccountR.bAccountID,
Where<Customer.type, IsNotNull,
Or<BAccountR.type, Equal<BAccountType.companyType>>>>),
Visibility = PXUIVisibility.SelectorVisible,
DescriptionField = typeof(Customer.acctName),
Filterable = true)]
public virtual int? CustomerID { get; set; }
public abstract class customerID : IBqlField { }
#endregion
#region InventoryID
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Inventory Item")]
[Inventory(typeof(Search<InventoryItem.inventoryID,
Where2<Match<Current<AccessInfo.userName>>,
And<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.unknown>>>>),
typeof(InventoryItem.inventoryCD), typeof(InventoryItem.descr),
Filterable = true)]
public virtual int? InventoryID { get; set; }
public abstract class inventoryID : IBqlField { }
#endregion
#region RebateAmt
[PXDBDecimal()]
[PXUIField(DisplayName = "Rebate Amount")]
public virtual Decimal? RebateAmt { get; set; }
public abstract class rebateAmt : IBqlField { }
#endregion
}
通用查询:
Tables: DPItemRebate.DPItemRebate
Relations: <none>
Results:
Object: DPItemRebate
Data Fields: vendorID, vendorID_description, customerID, customerID_description, inventoryID, inventoryID_description, rebateAmt
DAC 字段是查找,但返利除外。我从 Acumatica DAC 代码中的其他地方借用了选择器属性。我将所有字段添加到新的输入页面,使用新页面输入数据,然后打开通用查询,它给出了一个错误:
"[InvalidCastException: Specified cast is not valid.]
System.Data.SqlClient.SqlBuffer.get_Int32() +65
PX.Data.PXDataRecord.GetInt32(Int32 i) +96
PX.Data.PXDBIntAttribute.RowSelecting(PXCache sender, PXRowSelectingEventArgs e) +210
PX.Data.PXCache.OnRowSelecting(Object item, PXDataRecord record, Int32& position, Boolean isReadOnly) +650"
和
"[PXException: Error: An error occurred during processing of the field Customer: Specified cast is not valid..]"
当我注释掉供应商、客户活动和库存的 DAC 查找定义时;转换错误消失了,所以它可能相关;但我需要这些进行字段查找。我定义错了什么?
我将所有查找字段属性定义更改为基本 PXSelector 属性,它最终没有错误地工作。不过,我仍然不知道为什么其他Acumatica会抛出错误。
不要重新声明它已经在 [CustomerActive]
属性中定义[PXDBInt(IsKey = true)]
。