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

如何在Acumatica的Case页面(CR306000)添加跳转至销售订单页的动作

Redirecting to Sales Order Page from Case (CR306000) Action Button in Acumatica

Hey there! Great job getting the action button added to the Case page's Actions menu — that's a solid start. Let's dive right into the code you need to make that button redirect to the Sales Order page (SO301000), including both basic and parameterized scenarios.

Basic Redirect (No Parameters)

If you just need to open the Sales Order page directly without pre-filling any data, use this code in your action's handler method:

public PXAction<CRCase> redirectToSalesOrder;
[PXButton(CommitChanges = true)] // Critical: Saves current Case changes before redirecting
[PXUIField(DisplayName = "Go to Sales Order")]
protected void RedirectToSalesOrder()
{
    // Redirect to the Sales Order detail page (SO301000)
    throw new PXRedirectRequiredException(new SOOrderEntry(), null);

    // Alternatively, redirect to the Sales Order list page:
    // throw new PXRedirectRequiredException(typeof(SOOrderEntry), null, "Sales Orders");
}

If your Case is linked to a specific Sales Order (e.g., via an SOOrderNbr field on the CRCase DAC), you can jump directly to that order's detail page with this approach:

public PXAction<CRCase> redirectToAssociatedSalesOrder;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Open Linked Sales Order")]
protected void RedirectToAssociatedSalesOrder()
{
    CRCase currentCase = Base.Case.Current;
    if (currentCase == null) return;

    // Check if the Case has an associated Sales Order number
    if (string.IsNullOrEmpty(currentCase.SOOrderNbr))
    {
        throw new PXException("This Case has no associated Sales Order.");
    }

    // Fetch the linked Sales Order record
    SOOrder linkedOrder = PXSelect<SOOrder, 
        Where<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>
        .Select(Base, currentCase.SOOrderNbr);

    if (linkedOrder == null)
    {
        throw new PXException($"Sales Order {currentCase.SOOrderNbr} not found.");
    }

    // Redirect directly to the found Sales Order
    throw new PXRedirectRequiredException(linkedOrder, null);
}

Key Notes to Remember

  • CommitChanges = true: Always include this in the PXButton attribute to ensure any unsaved changes to the current Case are committed before navigating away.
  • PXRedirectRequiredException: This is Acumatica's standard way to trigger page navigation — it handles context switching properly, unlike manual URL redirects.
  • Permissions: Make sure the user role has access to the Sales Order page (SO301000); otherwise, the redirect will fail with a permission error.
  • Custom Parameters: If you need to pass other filters or default values to the Sales Order page, you can initialize the SOOrderEntry graph and set its view properties before throwing the exception:
    SOOrderEntry salesOrderGraph = PXGraph.CreateInstance<SOOrderEntry>();
    // Set default order type for the list view
    salesOrderGraph.Order.Current = new SOOrder { OrderType = "SO" };
    throw new PXRedirectRequiredException(salesOrderGraph, null);
    

Just drop this code into your existing Case page graph extension, and your action button will handle the redirect smoothly.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:19:14