Skip to main content
Solved

Device Hub Action for move screen


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;

 

View original
Did this topic help you find an answer to your question?

4 replies

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

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
  • Jr Varsity III
  • 17 replies
  • 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+13
  • 1715 replies
  • 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
  • Jr Varsity III
  • 17 replies
  • March 21, 2025

@darylbowman That worked. Thank you very much!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings