Make a Field Mandatory on the Graph Level

雨燕双飞 提交于 2019-12-13 03:35:38

问题


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.

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

Setup:


回答1:


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.



来源:https://stackoverflow.com/questions/49371209/make-a-field-mandatory-on-the-graph-level

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!