acumatica - 既然 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 和传递参数。
解决方案
我猜你在这里有两个选择:
创建作为
DashboardMaint
仪表板页面图形的图形实例,并提供仪表板的名称并调用该viewDashboard
图形的操作。只需获取 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);
}
该值的键是仪表板定义中的参数名称
推荐阅读
- paypal - 如何使用访客结账选项接受信用卡?贝宝
- r - 为什么我的饼图的某些部分在 ggplot 中丢失了?
- ios - In App Purchase - 检测用户是否已经购买
- vue.js - Vue Axios 不返回响应
- android - 如何处理 NativeScript 预览应用程序中缺少的插件
- python - 创建用于 k-medoids 的 csr_matrix
- google-cloud-run - 即使我的脚本仍在运行,云运行也会关闭容器
- java - javax.xml.ws.WebServiceException:未定义的端口类型,即使定义了端点接口
- algorithm - 递归树算法的运行时复杂度是多少,它在不同的子子树大小的数量上是二次的?
- android-studio - 如何通过 Androids Volley 包访问 api.openrouteservice.org