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:
- 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.
- Add the following assembiles to your customization:
- Epicor.Mfg.Core.BLConnectionPool
- Epicor.Mfg.Rpt.ISOPickListReport
- Epicor.Mfg.Rpt.SOPickListReport
- 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
- More blogs by Bryan Sapot
- The Datix Blog
- Meet our Consultants
- Learn more about Epicor ERP
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
Hi Leroy,
Glad we could help and thanks for getting in touch to let us know the code worked for you.
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
Great point. We will update the post.
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
FYI, I see that this is for E9 and we are on E10
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.
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
Is the same solution available for BAQ Report in Epicor 10 ?