如何在 2020R2 中将事件附加到客户屏幕上的住宅交付复选框?

How to attach an event to the Residential Delivery checkbox on the Customers screen in 2020R2?

我需要将客户 AR.30.30.00 屏幕(“运输”选项卡)上的“住宅交付”复选框的默认值更改为默认选中。见截图:

在 2017R2 中,此事件处理程序正常运行:

public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
    protected virtual void LocationExtAddress_CResedential_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
    {
        var row = (LocationExtAddress)e.Row;
        if (row != null)
        {
            e.NewValue = true; // checked by default
        }
    }
}

我正在为 2020R2 更新此自定义。在较新的版本中,LocationExtAddress 似乎已被替换为 DefLocationExt(Resedential 在代码中被故意拼写错误......这就是 Acumatica 定义它的方式。) 我尝试将事件处理程序更改为:

protected virtual void DefLocationExt_CResedential_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
    var row = (DefLocationExt)e.Row;
    if (row != null)
    {
        e.NewValue = true; // checked by default
    }
}

但这会导致 运行 时间错误:

Failed to subscribe the event PX.Objects.AR.CustomerMaint_Extension::DefLocationExt_CResedential_FieldDefaulting in the graph PX.Objects.AR.CustomerMaint. The method signature looks like an event handler, but the cache DefLocationExt has not been found in the list of auto-initialized caches. Remove unused event handlers from the code.

如何在 2020R2 中将事件附加到此字段?

尝试使用通用事件处理程序,看看是否会得到相同的结果。

它可能看起来像这样。

protected virtual void _(Events.FieldDefaulting<PX.Objects.CR.Standalone.Location.cResedential> e)
    {
        var row = (PX.Objects.CR.Standalone.Location)e.Row;
        if (row != null)
        {
            e.NewValue = true; // checked by default
        }
    }