Button to Print Pick Ticket from Order Entry – Epicor 9

Home  /  Solutions and Services  /  Epicor and ERP  /  Button to Print Pick Ticket from Order Entry – Epicor 9

button to print pick ticket Epicor 9

Order Entry – Epicor 9

As the leader in Epicor consulting, we like posting answers to common questions I see on forums. A lot of users want to be able to print reports directly from the entry screes like Order Entry. Below is some sample code on how to print the sales order pick ticket. This will submit the print request and open the report in preview mode.

Here are the steps:

  1.  Add a button to the summary tab. I’m assuming you know how to place a button on the screen and create a button click event. You can look at the article on Automatic Pack Slitp Number Generation.
  2.  Add the following assembiles to your customization:
    • Epicor.Mfg.Core.BLConnectionPool
    • Epicor.Mfg.Rpt.ISOPickListReport
    • Epicor.Mfg.Rpt.SOPickListReport
  3. Add the following code to the button click event:
private static void btnPickList_Click(object sender, System.EventArgs args)
{
 Epicor.Mfg.Core.Session epiSession = default(Epicor.Mfg.Core.Session);
 epiSession = (Epicor.Mfg.Core.Session)SalesOrderForm.Session;
 Epicor.Mfg.Rpt.SOPickListReport rptSOPickList = new Epicor.Mfg.Rpt.SOPickListReport(epiSession.ConnectionPool);
 Epicor.Mfg.Rpt.SOPickListReportDataSet rptDSSOPickList = rptSOPickList.GetNewParameters();

 EpiDataView edvOrderHed = (EpiDataView)oTrans.EpiDataViews["OrderHed"];

 DateTime dtShipBy = default(DateTime);

 dtShipBy = Convert.ToDateTime(edvOrderHed.dataView[edvOrderHed.Row]["RequestDate"]);

 // You may need a wider date range to include releases out side the ship date on order header
 if (DateTime.Compare(DateTime.Today, dtShipBy) > 0) {
  rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["FromDate"] = dtShipBy.AddDays(-1);
 } else {
  rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["ToDate"] = dtShipBy.AddDays(1);
 }

 rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["OrderList"] = edvOrderHed.dataView[edvOrderHed.Row]["OrderNum"];
 rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["AutoAction"] = "Preview";
 //Set this to your task agent id.
 rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["AgentID"] = "TaskAgnt";

 //The report style you want to print.
 rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["ReportStyleNum"] = 1002;
 rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["WorkstationID"] = Environment.MachineName + ” ” + Process.GetCurrentProcess().SessionId.ToString();
 rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["DateFormat"] = "mm/dd/yyyy";
 rptDSSOPickList.Tables["SOPickListReportParam"].Rows[0]["NumericFormat"] = ",.";

 // TaskAgnt is the ID of your task agent.
 rptSOPickList.SubmitToAgent(rptDSSOPickList, "TaskAgnt", 0, 0, "Epicor.Mfg.UIRpt.SOPickListReport");

 MessageBox.Show("Pick List Print Job Submitted.");
}

Suggested

9 Comments so far:

  1. Leroy says:

    Bryan,

    Thanks for the code, used it to print the expense report from expense entry. It works brilliantly and much easier then the reflection method. Also provides total control to data being passed to the task agent.

    Leroy

  2. Chris Lorenz says:

    Here’s a suggestion on your code for WorkstationID:
    Use a dynamic session ID, rather than assuming it is “1”. This will mostly be a problem with terminal services sessions, where the ID may or may not be 1. I have heard of this problem on client workstations too, though I haven’t experienced it.

    Change:
    …Rows[0][“WorkstationID”] = Environment.MachineName + ” 1″;
    To:
    …Rows[0][“WorkstationID”] = Environment.MachineName + ” ” + Process.GetCurrentProcess().SessionId.ToString();

    Process is under System.Diagnostics, so either preface Process with that or add a using statement.

    Chris

  3. bud.manz says:

    Hi,

    I am trying to use this code in a form customization and can’t seem to locate where the assemblies are to include that are listed in step 2. Can you point me in the right direction?

    Thanks,
    Bud

    • bud.manz says:

      FYI, I see that this is for E9 and we are on E10

      • Pierre says:

        How do you implement the same functionality (and what assemblies are needed) to implement this in version 10? I am trying with no success.! It is exactly what I need. From the order entry, we want to print the PickList for a specific Order, instead of going through the menu and select the report….and research for the Order….very combersome….
        I tried to use the Context menu, but always getting errors…as the filter does not seem to show properly.

  4. Andrew Saldivar says:

    Great stuff. This is information I’ve spent a bit of time looking for.
    Is there any chance that this is workable for a BAQ Report?

    If you could point me in the right direction, I’m sure Id be able to adapt the code.
    Perhaps there’s something in Object Explorer I could look at in order to determine the necessary elements?

    Any feedback would be truly appreciated.

    – Andrew

Leave a Reply

Your email address will not be published. Required fields are marked *