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
}
}