首页 > 解决方案 > 在 APInvoice DAC 上使用 APRegisterExt

问题描述

我有这种情况,即自定义字段位于 APRegisterExt DAC 上。而 APInvoice 继承自 APRegister。

虽然,我在做

APRegisterExt InvoiceDataExt = InvoiceData.GetExtension<APRegisterExt>();

它在编译时没有错误,但在运行时它给了我错误

“getItemExtension 失败”

我只想以编程方式在自定义字段上设置一个值。

谢谢!!!

标签: acumatica

解决方案


这在一定程度上取决于您要覆盖的事件。例如,如果您在 APTran_RowSelecting 事件中,您将像这样拉入 APTranExt:

public void APTran_RowSelecting(PXCache sender, PXRowSelectingEventArgs e)
        {
            APTran row = (APTran)e.Row;
            if (row == null) return;
            APTranExt ext = sender.GetExtension<APTranExt>(row);
        }

或者假设您在采购订单输入屏幕中,您点击 POLine_RowSelected 事件,但您需要行中库存项目的库存项目扩展值。你会做这样的事情:

// code to PXSelect the Inventory Item record 
// and assign it to the inventoryitem var.
InventoryItemExt inventoryitemext = PXCache<InventoryItem>.GetExtension<InventoryItemExt>(inventoryitem);

其中一种模式应该适合您。


推荐阅读