1

屏幕: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)
    { }
}}

这是我第一次必须在运行时更改属性,所以我不知道我不知道什么。

4

1 回答 1

1

我将使用缓存附加事件将默认/必需集附加到属性。您必须合并属性,并按照选择器从联系人到 BAccount。然后它将它与创建的常量进行比较。这段代码在我的演示环境中工作,全部在 CustomerMaint 图中。

//create constant class to check the CustomerClassID that is a string
public const string AttentionRequiredCustomerClass = "2";
public class attentionRequiredCustomerClass : PX.Data.BQL.BqlString.Constant<attentionRequiredCustomerClass>
{
    public attentionRequiredCustomerClass() : base(AttentionRequiredCustomerClass) {; }
}

//////merge the attribute with the existing, setting the making Attention required when CustomerClassID = 2
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
[PXMergeAttributes(Method = MergeMethod.Merge)]
//selector follows the contact's baccount to get the customer class, and compares it to the bql constant created above.
[PXUIRequired(typeof(Where<Selector<Contact.bAccountID, Customer.customerClassID>, Equal<attentionRequiredCustomerClass>>))]
protected virtual void Contact_Attention_CacheAttached(PXCache cache)
{ }
于 2019-09-19T18:58:47.637 回答