You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否在AP301000界面自定义属性区添加代码隐藏指定下拉选项?

Answer

Absolutely, you can hide the "Credit Adj." and "Prepayment" options from the Type dropdown in the Bills and Adjustments (AP301000) screen using custom code in the Customize Attributes area. Here's a straightforward, step-by-step breakdown to make this happen:

Step 1: Access the Field's Customization Settings

  1. Open the AP301000 screen and switch to Customization Mode (click the customization icon in the top-right corner).
  2. Locate the Type field in the document's Summary section.
  3. Right-click the field and select Properties to open its attribute configuration panel.

Step 2: Add Custom Code via the FieldSelecting Event

In the field properties window, find the Customize Attributes section. The FieldSelecting event is ideal here—it’s specifically designed to modify the available values for dropdown fields. Paste this code into the event’s code editor:

protected void APInvoice_Type_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
    // Grab the original list of Type dropdown options
    var originalOptions = (IEnumerable<KeyValuePair<string, string>>)e.ReturnValue;
    if (originalOptions == null) return;

    // Filter out the unwanted options
    e.ReturnValue = originalOptions
        .Where(opt => opt.Value != "Credit Adj." && opt.Value != "Prepayment")
        .ToList();
}

Quick Adjustment Notes:

  • If you’re using a non-English Acumatica instance, replace the string values ("Credit Adj.", "Prepayment") with the exact localized labels for these options in your system.
  • This runtime modification doesn’t alter core system data, so it’s safe for customizations and won’t impact unrelated workflows unless you explicitly code it to.

Alternative: RowSelected Event Approach

If you prefer, you can use the RowSelected event to update the dropdown list when a row loads. This works similarly but triggers when the row is rendered on the screen:

protected void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
    var invoice = e.Row as APInvoice;
    if (invoice == null) return;

    var typeFieldState = cache.GetStateExt<APInvoice.type>(invoice) as PXStringState;
    if (typeFieldState != null)
    {
        typeFieldState.ValueList = typeFieldState.ValueList
            .Where(item => item.Description != "Credit Adj." && item.Description != "Prepayment")
            .ToList();
        cache.SetStateExt<APInvoice.type>(invoice, typeFieldState);
    }
}

Final Validation

After adding the code, publish your customization project and test the AP301000 screen. Confirm the unwanted options no longer appear in the Type dropdown, and double-check related workflows (like payment processing or reporting) to ensure no unintended side effects.

内容的提问来源于stack exchange,提问作者Tim Rodman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:45:46