屏幕:AR303000 版本/内部版本 19.104.0024
我需要在运行时将注意力、数据字段、属性设置为 PXPersistingCheck.NullOrBlank。
逻辑:当 CustomerClassID = 2 时,注意字段必须更改为必需。ElseIF CustomerClassID<>2 则该字段设置为不需要。(这应该在运行时和加载时计算)
我试过使用:
PXDefaultAttribute.SetPersistingCheck<Contact.attention>(cache, row, PXPersistingCheck.NullOrBlank);
PXUIFieldAttribute.SetRequired<Contact.attention>(cache, true);
Hier 是我当前的代码:
namespace PX.Objects.AR
{
public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
protected void Customer_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = (Customer)e.Row;
CustomerClassID =row.CustomerClassID;
if (row.CustomerClassID == "02")
{
//throw new PXException("Test if you hit this code at runtime");
PXDefaultAttribute.SetPersistingCheck<Contact.attention>(cache, row, PXPersistingCheck.NullOrBlank);
}
else
{
PXDefaultAttribute.SetPersistingCheck<Contact.attention>(cache, row, PXPersistingCheck.NullOrBlank);
}
}
}
}
/// 我也尝试过覆盖屏幕级别的属性:
namespace PX.Objects.AR
{
public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
[PXDBString(255, IsUnicode = true)]
[PXUIField(DisplayName = "Attention")]
[PXMassMergableField]
[PXMassUpdatableField]
[PXPersonalDataField]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIRequired(typeof(Where<Customer.customerClassID, Greater<decimal_1>>))]
protected virtual void Contact_Attention_CacheAttached(PXCache cache)
{ }
}}
这是我第一次必须在运行时更改属性,所以我不知道我不知道什么。