【发布时间】:2019-03-07 00:55:05
【问题描述】:
我有一些可以运行的东西,但肯定看起来不正确
Desire:添加一个字段作为 CustomerPaymentMethod 的扩展 代码/表格都在下面
问题: 为什么需要 PaymentMethodID 字段,如果需要,如何填写?
在 DB Table OR Dac 中没有这个就开始了。这在直接访问 AR303010(客户付款方式)时加载/工作,但在来自 AR303000(AR 客户)的 SQL 连接上失败
如果我只是添加到表中,然后得到“无法将 null 插入字段”
如果我添加到 DAC 中,则在 DB 中继续获取 Null(仅在扩展表上)
所以这会运行,但肯定看起来不正确。我希望扩展表上不需要 PaymentMethodID,因为在“CustomerPaymentMethod.cs”的 DAC 中,它没有标记为“IsKey=true”。如果我确实需要它,那么我希望它作为密钥的一部分自动填充
表:
Create Table XPMCustomerPaymentMethodExt (
[CompanyID] [int] NOT NULL DEFAULT ((0)),
[PMInstanceID] [int] NOT NULL,
[BAccountID] [int] NOT NULL,
[PaymentMethodID] [nvarchar](10) NULL, /* Problem Child, if not here, fails to load customer screen (AR303000) */
[CanConsolidate] [bit] NULL,
[DeletedDatabaseRecord] [bit] NOT NULL DEFAULT ((0)),
CONSTRAINT [PK_XPMCustomerPaymentMethodExt] PRIMARY KEY CLUSTERED
(
[CompanyID] ASC,
[PMInstanceID] ASC
)
)
DAC:
[PXTable(IsOptional = true)]
public class XPMCustomerPaymentMethodExt : PXCacheExtension<PX.Objects.AR.CustomerPaymentMethod>
{
#region CanConsolidate
public abstract class canConsolidate : PX.Data.IBqlField
{
}
protected bool? _CanConsolidate = false;
[PXDBBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Payments may be consolidated")]
public virtual bool? CanConsolidate
{
get
{
return _CanConsolidate;
}
set
{
_CanConsolidate = value;
}
}
#endregion
#region PaymentMethodID
public abstract class paymentMethodID : PX.Data.IBqlField
{
}
protected string _PaymentMethodID; // = Base.PaymentMethodID;
[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXDBString(10, IsUnicode = true)]
//[PXDefault(typeof(CustomerPaymentMethod.paymentMethodID), PersistingCheck = PXPersistingCheck.Nothing)]
//[PXFormula(typeof(Selector<CustomerPaymentMethod.pMInstanceID, CustomerPaymentMethod.paymentMethodID>))]
public virtual String PaymentMethodID
{
get
{
//return Base.PaymentMethodID;
return _PaymentMethodID;
}
set
{
// Base.PaymentMethodID = value;
_PaymentMethodID = value;
}
}
#endregion
}
【问题讨论】:
-
“无法在字段中插入空值”是否正是显示的错误消息?我觉得措辞很奇怪,我怀疑错误消息和跟踪是不同的。
-
SQL(是的,纯测试框,是的,知道完整性违规):删除 XPMCustomerPaymentMethodExt 删除 CustomerPaymentMethod 从扩展名中注释掉整个 PaymentMethodID 字段,同时删除 PaymentMethodID 和 paymentMethodID 直接打开 AR303010(客户付款方式)输入数据,尝试保存来自 SalesDemo 数据集的数据:客户:ABARTENDE 付款方式:VISA 处理器默认值,至 AUTDOTNET 卡号(测试):4111111111111111 到期日期:12/21 名称:abc CVV:123 保存工作正常。表的 PaymentMethodID 字段为 NULL
-
来自客户的问题,连接包括对 PaymentMethodID 的引用(评论太长,从 SQL Profiler 获取):CustomerPaymentMethodInfo_CustomerPaymentMethod_XPMCustomerPaymentMethodExt -> longname LEFT JOIN [XPMCustomerPaymentMethodExt] [longname] ON ([longname].[CompanyID] ] = 2) AND [longname].[DeletedDatabaseRecord] = 0 AND [CustomerPaymentMethodInfo_CustomerPaymentMethod_CustomerPaymentMethod].[PMInstanceID] = [longname].[PMInstanceID] AND [CustomerPaymentMethodInfo_CustomerPaymentMethod_CustomerPaymentMethod].[PaymentMethodID] = [longname].[PaymentMethodID])
标签: extension-methods acumatica