在没有右侧导航窗格的情况下以弹出窗口形式打开 Acumatica 屏幕
Open Acumatica screen as popup without righthand navigation pane
我有使用以下代码打开 Acumatica 屏幕的代码:
var url = "http://localhost/AcumaticaDB2562/?ScreenId=AC302000&OpenSourceName=Bills+and+Adjustments&DataID=" + apinvoice.RefNbr;
throw new PXRedirectToUrlException(url, "Open Source")
{
Mode = PXBaseRedirectException.WindowMode.NewWindow
};
我通过查询字符串传递参数的地方。这工作正常,但我希望它在没有左侧导航窗格的情况下打开,类似于从 'Business Accounts' 案例选项卡中的案例列表打开案例时发生的情况。
另外 - 有没有办法指定或检索我所在的当前 Acumatica 实例的 url?
Peter,PXRedirectToUrlException 不是为了打开 Acumatica 屏幕。正如 Brendan 之前建议的那样 (),您应该使用 PXRedirectRequiredException 并将模式 属性 设置为 NewWindow。
下面的代码片段显示了如何在发票屏幕上创建一个按钮,以在没有左侧导航窗格的情况下在新 window 中打开为发票生成的批次:
public class SOInvoiceEntryExt : PXGraphExtension<SOInvoiceEntry>
{
public void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ARInvoice doc = (ARInvoice)e.Row;
if (doc == null) return;
OpenBatch.SetEnabled(doc.BatchNbr != null);
}
public PXAction<ARInvoice> OpenBatch;
[PXButton]
[PXUIField(DisplayName = "Open Batch")]
protected void openBatch()
{
ARInvoice doc = Base.Document.Current;
if (doc != null && doc.BatchNbr != null)
{
JournalEntry entry = PXGraph.CreateInstance<JournalEntry>();
entry.BatchModule.Current = entry.BatchModule.Search<Batch.batchNbr>(doc.BatchNbr, "AR");
if (entry.BatchModule.Current != null)
{
throw new PXRedirectRequiredException(entry, "Open Invoice Batch")
{
Mode = PXBaseRedirectException.WindowMode.NewWindow
};
}
}
}
}
切换到 PXRedirectRequiredException 后,您将不必检索当前 Acumatica 实例的 url。
假设您开发了一个自定义屏幕,它可以从导航窗格中正常打开:
namespace ActionMenuAddOn
{
public class TaskTemplateMaint : PXGraph<TaskTemplateMaint, TaskTemplate>
{
public PXSelect<TaskTemplate> Templates;
}
}
但是,在新 window 中打开自定义屏幕时抛出 PXRedirectRequiredException,我们收到错误“您没有足够的权限访问对象 (TaskTemplateMaint)”:
using ActionMenuAddOn;
...
namespace PX.Objects.SO
{
public class SOInvoiceEntryExt : PXGraphExtension<SOInvoiceEntry>
{
public void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ARInvoice doc = (ARInvoice)e.Row;
if (doc == null) return;
OpenTaskTemplate.SetEnabled(doc.BatchNbr != null);
}
...
public PXAction<ARInvoice> OpenTaskTemplate;
[PXButton]
[PXUIField(DisplayName = "Open Task Template")]
protected void openTaskTemplate()
{
TaskTemplateMaint templateMaint = PXGraph.CreateInstance<TaskTemplateMaint>();
templateMaint.Templates.Current = templateMaint.Templates.Search<TaskTemplate.templateCD>("000001");
if (templateMaint.Templates.Current != null)
{
throw new PXRedirectRequiredException(templateMaint, "Open Task Template")
{
Mode = PXBaseRedirectException.WindowMode.NewWindow
};
}
}
}
}
要克服错误,请打开 按角色访问权限 屏幕并至少向管理员角色授予自定义屏幕的访问权限,如下面的屏幕截图所示:
我有使用以下代码打开 Acumatica 屏幕的代码:
var url = "http://localhost/AcumaticaDB2562/?ScreenId=AC302000&OpenSourceName=Bills+and+Adjustments&DataID=" + apinvoice.RefNbr;
throw new PXRedirectToUrlException(url, "Open Source")
{
Mode = PXBaseRedirectException.WindowMode.NewWindow
};
我通过查询字符串传递参数的地方。这工作正常,但我希望它在没有左侧导航窗格的情况下打开,类似于从 'Business Accounts' 案例选项卡中的案例列表打开案例时发生的情况。
另外 - 有没有办法指定或检索我所在的当前 Acumatica 实例的 url?
Peter,PXRedirectToUrlException 不是为了打开 Acumatica 屏幕。正如 Brendan 之前建议的那样 (
下面的代码片段显示了如何在发票屏幕上创建一个按钮,以在没有左侧导航窗格的情况下在新 window 中打开为发票生成的批次:
public class SOInvoiceEntryExt : PXGraphExtension<SOInvoiceEntry>
{
public void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ARInvoice doc = (ARInvoice)e.Row;
if (doc == null) return;
OpenBatch.SetEnabled(doc.BatchNbr != null);
}
public PXAction<ARInvoice> OpenBatch;
[PXButton]
[PXUIField(DisplayName = "Open Batch")]
protected void openBatch()
{
ARInvoice doc = Base.Document.Current;
if (doc != null && doc.BatchNbr != null)
{
JournalEntry entry = PXGraph.CreateInstance<JournalEntry>();
entry.BatchModule.Current = entry.BatchModule.Search<Batch.batchNbr>(doc.BatchNbr, "AR");
if (entry.BatchModule.Current != null)
{
throw new PXRedirectRequiredException(entry, "Open Invoice Batch")
{
Mode = PXBaseRedirectException.WindowMode.NewWindow
};
}
}
}
}
切换到 PXRedirectRequiredException 后,您将不必检索当前 Acumatica 实例的 url。
假设您开发了一个自定义屏幕,它可以从导航窗格中正常打开:
namespace ActionMenuAddOn
{
public class TaskTemplateMaint : PXGraph<TaskTemplateMaint, TaskTemplate>
{
public PXSelect<TaskTemplate> Templates;
}
}
但是,在新 window 中打开自定义屏幕时抛出 PXRedirectRequiredException,我们收到错误“您没有足够的权限访问对象 (TaskTemplateMaint)”:
using ActionMenuAddOn;
...
namespace PX.Objects.SO
{
public class SOInvoiceEntryExt : PXGraphExtension<SOInvoiceEntry>
{
public void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ARInvoice doc = (ARInvoice)e.Row;
if (doc == null) return;
OpenTaskTemplate.SetEnabled(doc.BatchNbr != null);
}
...
public PXAction<ARInvoice> OpenTaskTemplate;
[PXButton]
[PXUIField(DisplayName = "Open Task Template")]
protected void openTaskTemplate()
{
TaskTemplateMaint templateMaint = PXGraph.CreateInstance<TaskTemplateMaint>();
templateMaint.Templates.Current = templateMaint.Templates.Search<TaskTemplate.templateCD>("000001");
if (templateMaint.Templates.Current != null)
{
throw new PXRedirectRequiredException(templateMaint, "Open Task Template")
{
Mode = PXBaseRedirectException.WindowMode.NewWindow
};
}
}
}
}
要克服错误,请打开 按角色访问权限 屏幕并至少向管理员角色授予自定义屏幕的访问权限,如下面的屏幕截图所示: