Make a Field Mandatory on the Graph Level

2019-08-23 07:03发布

Newbie to Acumatica here. I've performed a small amount of customization to our system, and am now diving into adding custom data fields.

My goal is to synchronize hardware shipment information from Acumatica into our legacy (outdated and proprietary) hardware management system, as we will need to continue using this system for the time being for warranty calculations. I plan to eventually build this into Acumatica.

My current issue is that I need a method of associating 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 documentation. I made the column be required by setting

[PXDefault]
[PXUIField(DisplayName="DCL Account ID", Required = true)]

to the attributes section of the Data Access class as outlined here. I then added the field to my form using the Layout Editor.

At this point all seemed well. The field shows an asterisk in the UI and also validates that a value is provided. Then I realized that Customer Locations is not the only place that uses CR.Location -- it is also used by 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.

Here is my CustomerLocationMaint code:

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
  }
}

After I save and publish the customization, the field does not function as a required field, as it did when I defined the requirements at the DAC level.

enter image description here

So, what have I done wrong? I've read and re-read the documentation multiple times, but cannot find my mistake.

Setup: CR.Location

Layout Editor: AR303020

CustomerLocationMaint

1条回答
Animai°情兽
2楼-- · 2019-08-23 07:48

My thought is the underscore in the field name causing the cache attached to not properly register the graph level attribute change. Using a field name without the underscore is the preferred naming convention for tables and columns.

The Acumatica documentation mentions this should be avoided as listed here: Database Design Guidelines

Found under Table and Column Naming Conventions:

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.

查看更多
登录 后发表回答