2

Acumatica offers a great feature to Save as Template which makes creating new records from the template faster and easier. However, I have a use case where I need a more interactive sort of template in which the user can create a list of 100 items and then select which items to include when creating the new record.

In this case, the standard feature for Save as Template could be confusing, especially for new users learning the system. I have been asked to disable Save as Template on the Copy/Paste menu on my custom screen and transition to this new feature. I do not want to disable Copy/Paste entirely, just the Template functionality. If I disable Copy/Paste in Access Rights, the entire menu disappears. However, the template options do not appear in Access Rights.

Copy/Paste appears to be accessible via code as the PXAction CopyPaste which can be hidden or disabled, but again, I cannot find SaveTemplate as a child that I can control.

How can I disable/hide Save as Template (CopyPaste@SaveTemplate) on an Acumatica screen, either programmatically, in access rights, or in workflow? This menu is part of the standard Acumatica menu system when specifying a primary DAC when defining the graph. Alternatively, I think it enabled via the PXCopyPasteAction<> action if manually defining buttons on the page.

Brian Stevens
  • 1,826
  • 1
  • 7
  • 16

2 Answers2

3

You can create your own PXCopyPasteAction by just extending the base class and then adding it to your graph

quick example below

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;
            }
        }
Markus Ray
  • 186
  • 2
1

The CopyPaste action is coming predefined as part of the PXGraph<TGraph,TPrimary> class. So you should be able to just simply do CopyPaste.SetEnabled(false) in the RowSelected event handler of your graph.

Another option is to try to override the CanClipboardCopyPaste virtual function of the PXGraph class.

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;
}
Samvel Petrosov
  • 7,580
  • 2
  • 22
  • 46
  • Disabling Copy/Paste is easy and has several ways to accomplish both via code and Access Rights. I just need to disable the Template portion of it. I think the previous answer may get me there, but I haven't made it back around to try it. I created a custom Add from Template action that works like the Add Item dialog as on PO's, and it's looking really nice. I want to allow users to continue to copy/paste this list, but I need them to use our custom "Add from Template" feature instead of the template features standard on Copy/Paste menu. – Brian Stevens Jan 13 '22 at 17:06