首页 > 解决方案 > 既然 GIScreenHelper 被标记为过时,我如何重定向到仪表板?

问题描述

我们有一个仪表板,可通过 Stocked Items 页面上的 Inquiry 菜单访问。在我们最近对 2019 R2 进行小升级之前,以下代码编译没有问题,允许打开与当前库存 ID 相关的仪表板。它仍然可以编译,但警告说 GIScreenHelper 已过时,将在下一次升级中标记为内部。因此我的问题是......如果我不能使用 GIScreenHelper 来初始化 PXRedirectRequiredException 中使用的图形,我该如何重定向到仪表板?

string screenID = "SS0010DB"; //DashboardID 
PXSiteMapNode sm = GIScreenHelper.GetSiteMapNode(screenID);
PXGraph graph = GIScreenHelper.InstantiateGraph(screenID);
if (graph is LayoutMaint)
{
    LayoutMaint copygraph = graph as LayoutMaint;
    Dictionary<string, object> parameters = new Dictionary<string, object>();

    parameters["InventoryID"] = item.InventoryCD;
    copygraph.Filter.Current.Values = parameters;

    throw new PXRedirectRequiredException(sm.Url, copygraph, PXBaseRedirectException.WindowMode.New, string.Empty);
}

我尝试过直接初始化 LayoutMaint,但我不知道要设置什么来指定要使用的屏幕 ID 和传递参数。

标签: acumatica

解决方案


我猜你在这里有两个选择:

  1. 创建作为DashboardMaint仪表板页面图形的图形实例,并提供仪表板的名称并调用该viewDashboard图形的操作。

  2. 只需获取 DashboardMaint 的viewDashboard操作代码并直接重定向到您的 Dashboard:

    [PXButton(ConfirmationType = PXConfirmationType.IfDirty, ConfirmationMessage = "Any unsaved changes will be discarded. Do you want to proceed?")]
    [PXUIField(DisplayName = "View")]
    public void viewDashboard()
    {
        throw new PXRedirectToUrlException(PXSiteMap.Provider.FindSiteMapNodeByScreenID(this.Dashboards.Current.ScreenID).Url, PXBaseRedirectException.WindowMode.Same, "View Dashboard");
    }
    

更新

下面是一个代码示例,如何使用过滤器的预定义值打开仪表板。该示例是为客户视图仪表板编写的。

[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "CustomerView")]
protected virtual IEnumerable RedirectToCustomerViewDashboard(PXAdapter adapter)
{
    string screenID = "DB000031"; //DashboardID 
    LayoutMaint graph;
    using (new PXScreenIDScope(screenID))
    {
        graph = PXGraph.CreateInstance<LayoutMaint>(screenID);
    }
    Dictionary<string, object> parameters = new Dictionary<string, object>();
    parameters["CustomerAccountID"] = "ABARTENDE";
    graph.Filter.Current.Values = parameters;
    throw new PXRedirectRequiredException(PXSiteMap.Provider.FindSiteMapNodeByScreenID(screenID).Url, graph, PXBaseRedirectException.WindowMode.New, string.Empty);
}

该值的键是仪表板定义中的参数名称

在此处输入图像描述


推荐阅读