首页 > 解决方案 > 客户所需的 BusinessAccountMaint 字段

问题描述

我正在尝试在创建商业帐户时设置它们所需的 PriceClassID。我最初是通过编辑 DAC 来做到这一点的。这导致了一个问题,即每当创建员工时,都会显示错误,从而无法创建员工。

错误:“CPriceClassID”不能为空

我回到绘图板并决定编辑图表上的属性,这允许我创建员工记录。但是,现在通过商业帐户屏幕编辑现有供应商时,我得到了同样的错误。我可以从供应商屏幕创建和编辑供应商,因为它使用不同的图表,但我仍然希望实现更优雅的解决方案

[PXDBString(10, IsUnicode = true)]
[PXSelector(typeof(AR.ARPriceClass.priceClassID))]
[PXUIField(DisplayName = "Price Class", Visibility = PXUIVisibility.Visible)]
[PXDefault()]    
protected virtual void Location_CPriceClassID_CacheAttached(PXCache sender)
{
}

在商业帐户屏幕上设置 CPriceClassID 字段的最佳方法是什么,仍然允许我创建员工和供应商而不会出现任何错误?

标签: acumatica

解决方案


你可以用它PXUIRequiredAttribute来实现你所需要的。下面是一个示例,说明如何使用它使字段仅在特定屏幕上是必需的:

public class LocationExt : PXCacheExtension<PX.Objects.CR.Location>
{
    public class BusinessAccountMaintScreen :Constant<string>
    {
        //"CR.30.30.00" is the page id of the Business Accounts screen
        public BusinessAccountMaintScreen():base("CR.30.30.00")
        {

        }
    }

    #region UsrCustomField
    [PXDBString(10, IsUnicode = true)]
    [PXSelector(typeof(AR.ARPriceClass.priceClassID))]
    [PXUIField(DisplayName = "Price Class", Visibility = PXUIVisibility.Visible)]
    [PXDefault]
    // Here we add checking for the current page so that this field will be required only on the Business Accounts screen
    [PXUIRequired(typeof(Where<Current<AccessInfo.screenID>, Equal<BusinessAccountMaintScreen>>))]

    public virtual String CPriceClassID {get;set;}
    #endregion
}

推荐阅读