在图形级别强制设置一个字段

Make a Field Mandatory on the Graph Level

这里是 Acumatica 的新手。我对我们的系统进行了少量自定义,现在正着手添加自定义数据字段。

我的目标是将 Acumatica 的硬件装运信息同步到我们遗留的(过时的和专有的)硬件管理系统中,因为我们暂时需要继续使用该系统进行保修计算。我计划最终将其构建到 Acumatica 中。

我当前的问题是我需要一种关联 Customer Locations to the customer locations in our legacy system. Adding the field DCL_ID was easy enough to accomplish following the To Add a Custom Data Field 文档的方法。我通过设置

使列成为必填项
[PXDefault]
[PXUIField(DisplayName="DCL Account ID", Required = true)]

到数据访问的属性部分 class as outlined here。然后,我使用 Layout Editor.

将该字段添加到我的表单中

此时一切似乎都很好。该字段在 UI 中显示星号,并验证是否提供了值。然后我意识到 Customer Locations 并不是唯一使用 CR.Location 的地方——Account Locations. Doing some digging I've found that Account Locations can include many more account types than Customer Locations. I only need this attribute to be required for Customer Locations. Thus, I have opted to use the To Make a Field Mandatory on the Graph Level.

也使用它

这是我的 CustomerLocationMaint 代码:

using System;
using PX.Data;
using PX.Objects.CR;
using System.Collections.Generic;
using PX.Objects;
using PX.Objects.AR;

namespace PX.Objects.AR
{
  public class CustomerLocationMaint_Extension : PXGraphExtension<CustomerLocationMaint>
  {
    #region Event Handlers

    [PXDefault]
    [PXCustomizeBaseAttribute(typeof(PXUIFieldAttribute), "Required", true)]
    protected virtual void SelectedCustomerLocation_UsrDCL_ID_CacheAttached(PXCache cache)
    {

    }

    #endregion
  }
}

在我保存并发布自定义后,该字段不再作为必填字段,就像我在 DAC 级别定义需求时那样。

那么,我做错了什么?我已经阅读并重新阅读了文档多次,但找不到我的错误。

设置:

我的想法是字段名称中的下划线导致附加的缓存无法正确注册图形级属性更改。使用不带下划线的字段名称是表和列的首选命名约定。

Acumatica 文档提到应该避免这种情况,如下所列: Database Design Guidelines

Table 和列命名约定下找到 :

Do not use the underscore symbol (_) in table or column names, because it is a reserved symbol in Acumatica Framework. For example, CompanyType is a valid column name, while Company_Type is invalid.