有没有办法用自定义项目删除现有的站点地图,类似于添加一个,或者我们是否需要执行自定义插件来删除它?
更新
我一直在尝试下面的解决方案,但我一直在收到错误。我在代码中搜索了站点地图维护,并在向导逻辑中找到了一个例程,但它不能在我的代码中工作。我检查了所有的包含,我有我需要的一切。
下面的选择显示错误说明"非静态字段,方法或属性需要对象引用' PXSelectBase.Select(params object [])'""
using Customization;
using PX.Data;
using PX.SM;
using System;
...
/// <summary>
/// Delete site map entry
/// </summary>
/// <param name="screenID">Sitemap screen ID</param>
protected virtual void DeleteSiteMap(string screenID)
{
if (string.IsNullOrWhiteSpace(screenID))
{
throw new ArgumentNullException("screenID");
}
SiteMap sitemap = PXSelect<SiteMap, Where<SiteMap.screenID, Equal<Required<SiteMap.screenID>>>>
.Select(this, screenID);
return;
// Edit:
// starting 2017R2 there could be MUI* tables witch references to the sitemap. These are the new workspaces.
// It would be a good idea to check these tables for reference to the deleting screen. This script was written in 6.1 which did not have the modern UI workspaces.
}
答案 0 :(得分:2)
我过去唯一的做法是使用customization plugin。您可以按屏幕ID查询站点地图表,如果找到则删除它。
这样的东西应该有效(虽然我没有测试过)。我确实从我们的升级插件中提取了一些内容以获得快速示例:
protected virtual void RemoveSiteMapEntry(PXGraph graph, string screenId)
{
PX.SM.SiteMap siteMap = PXSelect<PX.SM.SiteMap,
Where<PX.SM.SiteMap.screenID, Equal<Required<PX.SM.SiteMap.screenID>>>>.Select(graph, screenId);
if (siteMap == null)
{
return;
}
graph.Caches[typeof(PX.SM.SiteMap)].PersistDeleted(siteMap);
// Edit:
// starting 2017R2 there could be MUI* tables witch references to the sitemap. These are the new workspaces.
// It would be a good idea to check these tables for reference to the deleting screen. This script was written in 6.1 which did not have the modern UI workspaces.
}
或者,您可以编写PXDatabase.Delete
语句,而无需PXGraph
。我只在必要时使用PXDatabase
进行升级逻辑或批量处理记录。
您可以从Customization Plugin调用所有这些选项。对于图表,您需要先创建一个新实例,然后才能将其用作我的示例。