Auto Print Report From Customization

I would like to print a report from a customization.

I’m an experienced C# programmer and what I need help with is understanding whether, while using the BOs available for customizations, it is possible to print a Crystal or SSRS report. Specifically, a Bill of Lading report.

From looking the trace log, one of the BOs called during a manual print request (by printing via the menu) is Erp.Proxy.Rpt.BOLFormImpl and the method called is SubmitToAgent():

<tracePacket>
  <businessObject>Erp.Proxy.Rpt.BOLFormImpl</businessObject>
  <methodName>SubmitToAgent</methodName>
  <appServerUri>net.tcp://ejbdb10/ERP10_2_TEST/</appServerUri>
  <returnType>System.Void</returnType>
  <localTime>3/31/2021 09:52:43:4439843 AM</localTime>
  <threadID>1</threadID>
  <executionTime total="426" roundTrip="400" channel="0" bpm="1" other="25" />
  <retries>0</retries>
  <parameters>
    <parameter name="ds" type="Erp.Rpt.BOLFormDataSet">
      <BOLFormDataSet xmlns="http://www.epicor.com/Ice/300/Rpt/BOLForm/BOLForm" />
    </parameter>
    <parameter name="agentID" type="System.String"><![CDATA[SystemTaskAgent]]></parameter>
    <parameter name="agentSchedNum" type="System.Int64"><![CDATA[0]]></parameter>
    <parameter name="agentTaskNum" type="System.Int32"><![CDATA[0]]></parameter>
    <parameter name="maintProgram" type="System.String"><![CDATA[Erp.UIRpt.BOLForm]]></parameter>
  </parameters>
  <paramDataSetChanges>
    <paramDataSet name="ds" useDataSetNbr="0">
      [lots of data]
    </paramDataSet>
  </paramDataSetChanges>
  <serverTrace>
    <Op Utc="2021-03-31T14:52:43.4067805Z" act="Erp:Rpt:BOLForm/BOLFormSvcContract/SubmitToAgent" dur="381.7919" cli=[myClient] usr=[myUser] machine=[myMachine] pid="14772" tid="105" xmlns="">
      <Sql queries="8" cacheHits="0" time="38.2747" qryTypeCount="7" />
    </Op>
  </serverTrace>
</tracePacket>

I’ve looked into using Erp.Proxy.Rpt.BOLFormImpl and calling SubmitToAgent() via the customization with no success.

I’ve searched for a solution for days and didn’t come across a previous case on this, so your input is very appreaciated!

I hope this code will help you.

                Ice.Core.Session otSession = (Ice.Core.Session)this.oTrans.Session;
		String strWorkstationID = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID(otSession);

		Erp.Proxy.Rpt.BOLFormImpl report = 
                WCFServiceSupport.CreateImpl<Erp.Proxy.Rpt.BOLFormImpl>(otSession, 
                Epicor.ServiceModel.Channels.ImplBase<Erp.Contracts.BOLFormSvcContract>.UriPath);
		Erp.Rpt.BOLFormDataSet ds = report.GetNewParameters();
		
		ds.BOLFormParam[0].BOLNum = 1;
		ds.BOLFormParam[0].AutoAction = "SSRSPREVIEW";
		ds.BOLFormParam[0].AgentSchedNum = 0;
		ds.BOLFormParam[0].AgentID = "SystemTaskAgent";
		ds.BOLFormParam[0].AgentTaskNum = 0;
		ds.BOLFormParam[0].RecurringTask = false;
		ds.BOLFormParam[0].RptPageSettings = "";
		ds.BOLFormParam[0].RptPrinterSettings = "";
		ds.BOLFormParam[0].RptVersion = "";
		ds.BOLFormParam[0].ReportStyleNum = 2;
		ds.BOLFormParam[0].WorkstationID = strWorkstationID;
		ds.BOLFormParam[0].TaskNote = "";
		ds.BOLFormParam[0].ArchiveCode = 0;
		ds.BOLFormParam[0].DateFormat = "mm/dd/yyyy";
		ds.BOLFormParam[0].NumericFormat = ",.";
		ds.BOLFormParam[0].AgentCompareString = "";
		ds.BOLFormParam[0].ProcessID = "";
		ds.BOLFormParam[0].ProcessTaskNum = 0;
		ds.BOLFormParam[0].DecimalsPrice = 0;
		ds.BOLFormParam[0].GlbDecimalsGeneral = 0;
		ds.BOLFormParam[0].GlbDecimalsCost = 0;
		ds.BOLFormParam[0].GlbDecimalsPrice = 0;				
		ds.BOLFormParam[0].SSRSRenderFormat = "PDF";

		report.RunDirect(ds);
3 Likes

App.BOLEntry.BOLForm_Customization_boltest_CustomExport.xml (23.9 KB)

1 Like

This code works also, you can leave the Email part out

2 Likes

You may want to give this a read too. Nathan Anderson of Epicor explains:

Let’s talk about SSP (server-side printing) - Experts’ Corner

2 Likes

Thank you all for the direction. I’ll give it a try tonight and will report back on my progress.

This worked great. I just had to manually import Ice.Core.Session.dll (to get the workstation ID) and Erp.Contracts.Rpt.BOLForm.dll (to get the report parameters) via Assembly Reference Manager inside the customization and it worked.

Thank you!