如何禁用 Copy/Paste 保存模板操作?

How can I disable the Copy/Paste Save Template action?

Acumatica 提供了一个很棒的功能另存为模板,这使得从模板创建新记录变得更快、更容易。但是,我有一个用例,我需要一种更具交互性的模板,用户可以在其中创建一个包含 100 个项目的列表,然后 select 在创建新记录时要包含哪些项目。

在这种情况下,另存为模板的标准功能可能会造成混淆,尤其是对于学习该系统的新用户而言。我被要求在我的自定义屏幕上的 Copy/Paste 菜单上禁用另存为模板并过渡到此新功能。我不想完全禁用 Copy/Paste,只是禁用模板功能。如果我在访问权限中禁用 Copy/Paste,整个菜单就会消失。但是,模板选项不会出现在访问权限中。

Copy/Paste 似乎可以通过代码作为 PXAction CopyPaste 访问,它可以被隐藏或禁用,但同样,我找不到我可以控制的子 SaveTemplate。

如何在 Acumatica 屏幕上以编程方式、访问权限或工作流程disable/hide另存为模板 (CopyPaste@SaveTemplate)?在定义图形时指定主 DAC 时,此菜单是标准 Acumatica 菜单系统的一部分。或者,如果在页面上手动定义按钮,我认为它是通过 PXCopyPasteAction<> 操作启用的。

您可以创建自己的 PXCopyPasteAction,只需扩展基础 class,然后将其添加到您的图形中

下面的快速示例

public class CustomCopyPasteAction: PXCopyPasteAction<SOOrder>
        {
            public CustomCopyPasteAction(PXGraph graph, string name): base(graph, name) { }

            protected override void RowSelected(PXCache cache, PXRowSelectedEventArgs e)
            {
                base.RowSelected(cache, e);

                bmSaveTemplate.Enabled = false;
            }
        }

CopyPaste 操作即将预定义为 PXGraph<TGraph,TPrimary> class 的一部分。因此,您应该能够在图形的 RowSelected 事件处理程序中简单地执行 CopyPaste.SetEnabled(false)

另一种选择是尝试覆盖 PXGraph class 的 CanClipboardCopyPaste 虚函数。

public class PXGraph<TGraph, TPrimary> : PXGraph where TGraph : PXGraph where TPrimary : class, IBqlTable, new()
{
    public override bool CanClipboardCopyPaste()
    {
        return true;
    }

    /// <summary>The action that saves changes stored in the caches to the database. The code of an application graph typically saves changes through this action as well. To invoke it from code, use the PressSave() method of the Actions property.</summary>
    public PXSave<TPrimary> Save;

    /// <summary>The action that discard changes to the data from the caches.</summary>
    public PXCancel<TPrimary> Cancel;

    /// <summary>The action that inserts a new data record into the primary cache.</summary>
    public PXInsert<TPrimary> Insert;

    /// <summary>The action that deletes the Current data record of the primary cache.</summary>
    public PXDelete<TPrimary> Delete;

    /// <summary>The action that is represented on the user interface by an expandable menu that includes Copy and Paste items.</summary>
    public PXCopyPasteAction<TPrimary> CopyPaste;

    /// <summary>The action that navigates to the first data record in the primary data view. The data record is set to the Current property of the primary cache.</summary>
    public PXFirst<TPrimary> First;

    /// <summary>The action that navigates to the previous data record in the primary data view. The data record is set to the Current property of the primary cache.</summary>
    public PXPrevious<TPrimary> Previous;

    /// <summary>The action that navigates to the next data record in the primary data view. The data record is set to the Current property of the primary cache.</summary>
    public PXNext<TPrimary> Next;

    /// <summary>The action that navigates to the last data record in the primary data view. The data record is set to the Current property of the primary cache.</summary>
    public PXLast<TPrimary> Last;
}