Downloading SO Acknowledgement pdf programatically

Hi everyone,
I am trying to figure out a way to download the SO acknowledgement pdf programmatically. I’ve seen a post on how to submit one programatically but nothing on how to download it. And it doesn’t help that there is no documentation in the object explorer for Erp.UIRpt.SalesOrderAck. Is this even possible through the SalesOrderAck adapter?

1 Like

It should be possible using the RunDirect method on the BO. I can do it with REST.

Where do you find the documentation for that? I dont see it in the object explorer.

Like I said, I did it with REST and I’m assuming there’s got to be an associated method since I’ve always assumed that REST is just a wrapper around the BO. For example, to print the GL Book report, this is the REST endpoint:

api/help/v1/methods/Erp.RPT.GlBookReportSvc/index#!/Custom_methods/RunDirect

Dear @Inhol, Please use the below mentioned code to download the Sales Order Acknowledgement Report

private void btnPrintSOA_Click(object sender, System.EventArgs args)
{
	salesOrderAckAdapter soa = new salesOrderAckAdapter(oTrans);
	soa.BOConnect();
	soa.GetNewParameters();
	soa.ReportData.SalesOrderAckParam[0].OrderNum = 123770;
	soa.ReportData.SalesOrderAckParam[0].AutoAction = "PREVIEW";
	soa.ReportData.SalesOrderAckParam[0].AgentID = "SystemTaskAgent";
	soa.ReportData.SalesOrderAckParam[0].ReportStyleNum = 1003;
	soa.ReportData.SalesOrderAckParam[0].WorkstationID = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID((Ice.Core.Session)oTrans.Session);
	soa.ReportData.SalesOrderAckParam[0].ArchiveCode = 7;
	soa.SubmitToAgent("SystemTaskAgent",0,0);
	MessageBox.Show("Print Job Has been submitted.");
}

Hi Hari, that is what I have so far besides the SubmitToAgent function. But what path would this save to? and is it possible to specify this path?

It will save it to the server in the EpicorData\Reports folder by user who invoked it. I had asked earlier about saving it to a different location and it sounds like it’s not currently possible.

please correct me if I’m wrong

This is my current code. I checked the Firm Release All Checkbox and the message box shows up. However, when I check my EpicorData/Reports/InhoL, it’s completely empty. Am I missing something?

Also, I am doing it on the test environment.

private void OrderHed_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
// ** Argument Properties and Uses **
// args.Row[“FieldName”]
// args.Column, args.ProposedValue, args.Row
// Add Event Handler Code
switch (args.Column.ColumnName)
{
case “FirmReleaseAll_c”:
if ((bool)args.ProposedValue == true) {
salesOrderAckAdapter soa = new salesOrderAckAdapter(oTrans);
soa.BOConnect();
soa.GetNewParameters();
soa.ReportData.SalesOrderAckParam[0].OrderNum = (int)edvOrderHed.CurrentDataRow[“OrderNum”];
soa.ReportData.SalesOrderAckParam[0].AutoAction = “PREVIEW”;
soa.ReportData.SalesOrderAckParam[0].AgentID = “SystemTaskAgent”;
soa.ReportData.SalesOrderAckParam[0].ReportStyleNum = 1003;
soa.ReportData.SalesOrderAckParam[0].WorkstationID = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID((Ice.Core.Session)oTrans.Session);
soa.ReportData.SalesOrderAckParam[0].ArchiveCode = 7;
soa.SubmitToAgent(“SystemTaskAgent”,0,0);
MessageBox.Show(“SO Acknolwedge”);

  			oTrans.Update();
  			oTrans.Refresh();
  		}
  		break;

So, maybe another route is to act like the Report Monitor and pull the report the same way your desktop does and then move that to a location of your choice. After you submit, if you have the guid of the task, you should be able to retrieve it. (Remember to set the archive period to at least one day.)

But like I said, I can download the PDF with REST so PowerShell is going to be my tool of choice with that.

Did you do a trace? Are you filling in all of the required fields? Do you see anything scheduled in the System Agent?

Interesting…do you have an example? That’s exactly what I need for a project I’m working on

I have the Swagger input:

{
	"ds": {
		"GlBookParam": [{
			"SysRowID": "00000000-0000-0000-0000-000000000000",
			"AutoAction": "SSRSPREVIEW",
			"PrinterName": "",
			"AgentSchedNum": "0",
			"AgentID": "SystemTaskAgent",
			"AgentTaskNum": 0,
			"RecurringTask": false,
			"RptPageSettings": "",
			"RptPrinterSettings": "",
			"RptVersion": "",
			"ReportStyleNum": 2,
			"WorkstationID": "YOURWORKSTATION",
			"TaskNote": "Run from REST",
			"ArchiveCode": 7,
			"DateFormat": "m/d/yyyy",
			"NumericFormat": ",.",
			"AgentCompareString": "",
			"ProcessID": "",
			"ProcessCompany": "",
			"ProcessSystemCode": "",
			"ProcessTaskNum": 0,
			"DecimalsGeneral": 0,
			"DecimalsCost": 0,
			"DecimalsPrice": 0,
			"GlbDecimalsGeneral": 0,
			"GlbDecimalsCost": 0,
			"GlbDecimalsPrice": 0,
			"FaxSubject": "",
			"FaxTo": "",
			"FaxNumber": "",
			"EMailTo": "",
			"EMailCC": "",
			"EMailBCC": "",
			"EMailBody": "",
			"AttachmentType": "",
			"ReportCurrencyCode": "USD",
			"ReportCultureCode": "en-US",
			"SSRSRenderFormat": "PDF",
			"UIXml": "",
			"PrintReportParameters": false,
			"SSRSEnableRouting": false,
			"DesignMode": false,
			"RowMod": "A"
		}],
		"ReportStyle": [{
			"Company": "101",
			"ReportID": "GlBookRpt",
			"StyleNum": 2,
			"StyleDescription": "Standard - SSRS",
			"RptTypeID": "SSRS",
			"PrintProgram": "reports/BookListingReport/GlBook",
			"PrintProgramOptions": "",
			"RptDefID": "GlBookRpt",
			"CompanyList": "",
			"ServerNum": 0,
			"OutputLocation": "Database",
			"OutputEDI": "",
			"SystemFlag": true,
			"CGCCode": "",
			"SysRevID": "1163165034",
			"SysRowID": "a3affb50-a2cc-4008-84c9-9f9d0117a043",
			"RptCriteriaSetID": "",
			"RptStructuredOutputDefID": "",
			"StructuredOutputEnabled": false,
			"RequireSubmissionID": false,
			"AllowResetAfterSubmit": false,
			"HasBAQOrEI": false,
			"BitFlag": 0,
			"ReportRptDescription": "",
			"RptDefRptDescription": "",
			"RptTypeRptTypeDescription": "",
			"RowMod": ""
		}]
	}
}

The SysRowID and SysRevI might be different from yours for the report style section. You might play with a different AUTOACTION for different results. Again, the trace is your friend. :wink:

Well I’ve been able to print via the BO, but it either previews it to the user or it sends the file to the server location. Have you been able to invoke the report with REST/BO and download that file to a different location?

A trace reveals this order:

Poll with this command:

  <businessObject>Ice.Proxy.BO.ReportMonitorImpl</businessObject>
  <methodName>GetRowsKeepIdleTimeWithBallonInfo</methodName>
...
    <parameter name="whereClauseSysRptLst" type="System.String"><![CDATA[((PrintDriver='TEXT' AND (AutoAction='PRINT' OR AutoAction='PREVIEW')) OR (PrintDriver='CRYSTAL' AND (AutoAction='PRINT' OR AutoAction='AUTOPRT' OR AutoAction='PREVIEW' OR AutoAction='AUTOPRV')) OR (PrintDriver='EPIFIN' AND (AutoAction='PRINT' OR AutoAction='PREVIEW')) OR (PrintDriver='BARTENDER' AND (AutoAction='AUTOPRT' OR AutoAction='AUTOPRV')) OR (PrintDriver='EDI' AND AutoAction<>'') OR (PrintDriver='SSRS' AND (AutoAction='PREVIEW' OR AutoAction='PRINT') AND LastAction='SSRSREADY')) AND WorkStationID='WORKSTATION']]></parameter>

I would probably use a different whereClause to restrict to the report I’m looking for, and checking for errors.

Once the result set comes in they call:

  <businessObject>Ice.Proxy.BO.ReportMonitorImpl</businessObject>
  <methodName>Update</methodName>

It updates the Status to In Process then it grabs the report stream:

  <businessObject>Ice.Proxy.BO.ReportMonitorImpl</businessObject>
  <methodName>GetReportBytes</methodName>
  <returnType>System.Byte[]</returnType>

Once you have your bytes, you save to a location of your choice.

Finally, call update again to change your status to Preview or Printed or whatever.

4 Likes

Hi guys,

Can we get the final code sample? Please?

I’m working on printing an invoice directly to the server then immediately attach it to the invoice record. the attachment comes later, but I’m in desperate need to print the report as PDF through code.

Thank you in advance.

Try this,

The PDF document itself also exists in the database, right after generation, in the SysRptLsts table.

First, submit your task, then check the SysTask table until your task has TaskStatus == “COMPLETE”.

Then go look into SysRptLsts, for your SysTaskNum. If you don’t find your task, then wait a bit and keep checking (on a timeout). Once you have the SysRptLsts row for your task, the PDF binary data is in the RptData field.

3 Likes