Skip to main content
Solved

Device Hub Action for move screen

  • March 21, 2025
  • 4 replies
  • 76 views

Forum|alt.badge.img

I am trying to add an action on the move screen to print a report via device hub. I was trying to follow the Acumatica post below and modify it for my needs . I am also including some others that i tried to use to help me, but i am clearly doing something wrong. I have very little knowledge of C# so its very possible it is a simple error that I dont know about. Below is my entire code. Any help would be greatly appreciated.

https://stackoverflow.com/questions/52117362/custom-print-invoice-action-on-process-screen

https://bstevens.net/brian/printing-to-a-label-printer-via-device-hub/

 

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

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

                [PXUIField(DisplayName = "Print Move with DeviceHub")]
                [PXButton]
                public virtual IEnumerable Print(PXAdapter adapter)
                {
                    AMBatch batch = Base.Document.Current;
        
                    Dictionary<string, string> parametersDictionary = new Dictionary<string, string>();
                    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
  }
}

Best answer by darylbowman

Change AMBatch batch = Base.Document.Current; to AMBatch batch = Base.batch.Current;

You’ll need all these:

using System.Collections.Generic;
using System.Collections;
using PX.SM;

 

4 replies

darylbowman
Captain II
Forum|alt.badge.img+15

What is the indication that you are ‘clearly doing something wrong’? Are you receiving errors?

 

Does your report have a parameter called ‘Batch’ expecting BatNbr?


Forum|alt.badge.img
  • Author
  • Varsity III
  • March 21, 2025

@darylbowman The first error that i get is below. When i looked up this error, it says that this is usually “ caused by using “using System.Collections.Generic;” (this was generated by acumatica) but if its changed to “using System.Collections” then it will work.

When i make that change, i then get the below errors. Im still looking into these so i havent found a way to fix them yet.

 


darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • March 21, 2025

Change AMBatch batch = Base.Document.Current; to AMBatch batch = Base.batch.Current;

You’ll need all these:

using System.Collections.Generic;
using System.Collections;
using PX.SM;

 


Forum|alt.badge.img
  • Author
  • Varsity III
  • March 21, 2025

@darylbowman That worked. Thank you very much!