Skip to main content
Answer

nearly identical actions on the same screen.

  • May 1, 2025
  • 2 replies
  • 53 views

Forum|alt.badge.img

Hello Community,

I need to add two nearly identical actions to the move screen. Each one points to a specific printer. I am then going to have a business event execute the action. I am having issues with getting both to show up. I have tried a few different ways to make it work and they arent both posting. Only one will post. i tried separate customization projects (with different names) and i tried putting them both in the same project but only one will be available. Could someone tell me what i need to do so that both will show up? Code is below.  Any help would be greatly appreciated. Im pretty sure its something simple that i am just overlooking.

using PX.Data;
using PX.Objects.CS;
using PX.Objects.AM.Attributes;
using System;
using System.Collections.Generic;
using System.Collections;
using PX.Objects;
using PX.Objects.AM;
using System.Threading;
using PX.SM;

namespace PX.Objects.AM
{
          
  public class MoveEntry_Extension2 : PXGraphExtension<PX.Objects.AM.MoveEntry>
  {
    #region Event Handlers
  
        public PXAction<AMBatch> print;

                [PXUIField(DisplayName = "Print 1010 Move with DeviceHub", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true, Visible = false)]
                [PXButton]
                public virtual IEnumerable Print(PXAdapter adapter)
                {
                    AMBatch batch = Base.batch.Current;
        
                    Dictionary<string, string> parametersDictionary = new Dictionary<string, string>();
                    parametersDictionary["DocType"] = batch.DocType;
                    parametersDictionary["Batch"] = batch.BatNbr;

                     SMPrinter printer = PXSelect<SMPrinter, Where<SMPrinter.printerName,
                Equal<Required<SMPrinter.printerName>>>>.Select(Base, "1010SAW");

                    PrintSettings printSettings = new PrintSettings()
                    {
                        PrinterID = printer.PrinterID,
                        NumberOfCopies = 1,
                        PrintWithDeviceHub = true,
                        DefinePrinterManually = true
                    };
        
                    PXGraph.CreateInstance<SMPrintJobMaint>().CreatePrintJob(printSettings,"AM615130",parametersDictionary,"Saw Move Verify",CancellationToken.None);
        
                   return adapter.Get();
                }
                  
     
    #endregion
        
  }
    
 }
 
 namespace PX.Objects.AM
{                 
  public class MoveEntry_Extension4 : PXGraphExtension<PX.Objects.AM.MoveEntry>
  {
    #region Event Handlers
  
        public PXAction<AMBatch> print;

                [PXUIField(DisplayName = "Print 2400 batch with DeviceHub", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true, Visible = false)]
                [PXButton]
                public virtual IEnumerable Print(PXAdapter adapter)
                {
                    AMBatch batch = Base.batch.Current;
        
                    Dictionary<string, string> parametersDictionary = new Dictionary<string, string>();
                    parametersDictionary["DocType"] = batch.DocType;
                    parametersDictionary["Batch"] = batch.BatNbr;

                     SMPrinter printer = PXSelect<SMPrinter, Where<SMPrinter.printerName,
                Equal<Required<SMPrinter.printerName>>>>.Select(Base, "2400SAW");

                    PrintSettings printSettings = new PrintSettings()
                    {
                        PrinterID = printer.PrinterID,
                        NumberOfCopies = 1,
                        PrintWithDeviceHub = true,
                        DefinePrinterManually = true
                    };
        
                    PXGraph.CreateInstance<SMPrintJobMaint>().CreatePrintJob(printSettings,"AM615130",parametersDictionary,"Saw Move Verify",CancellationToken.None);
        
                   return adapter.Get();
                }
    #endregion
        
  }
                       
}

Best answer by brendanhennelly02

Hi Justen, I would declare your actions with different variable names. The actions all roll into a single collection of action names and they should be unique.

 

Try something like this…

public PXAction<AMBatch> print1010;

[PXUIField(DisplayName = "Print 1010 Move with DeviceHub", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true, Visible = false)]
[PXButton]
public virtual IEnumerable Print1010(PXAdapter adapter)
{
// ...
}

public PXAction<AMBatch> print2400;

[PXUIField(DisplayName = "Print 2400 batch with DeviceHub", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true, Visible = false)]
[PXButton]
public virtual IEnumerable Print2400(PXAdapter adapter)
{
// ...
}

 

2 replies

brendanhennelly02
Acumatica Employee

Hi Justen, I would declare your actions with different variable names. The actions all roll into a single collection of action names and they should be unique.

 

Try something like this…

public PXAction<AMBatch> print1010;

[PXUIField(DisplayName = "Print 1010 Move with DeviceHub", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true, Visible = false)]
[PXButton]
public virtual IEnumerable Print1010(PXAdapter adapter)
{
// ...
}

public PXAction<AMBatch> print2400;

[PXUIField(DisplayName = "Print 2400 batch with DeviceHub", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Enabled = true, Visible = false)]
[PXButton]
public virtual IEnumerable Print2400(PXAdapter adapter)
{
// ...
}

 


Forum|alt.badge.img
  • Author
  • Varsity III
  • May 1, 2025

@brendanhennelly02 That worked. Thank you very much! I had tried changing the “public PXAction<Ambatch> print” to something else, but i didnt change it at the IEnumberable level.