Rest Service - Triggering Printing from REST service

Hey guys. I am working on an application which uses the rest service and I wanted to trigger a report and submit this to bartender for printing. I am curious to hear if anyone else has successfully achieved this or if it is possible from the current REST service, any insight would be appreciated.

Realised that the service list was hiding the required services in order to trigger prints

(ERP.RPT methods arent shown in service list)

Was able to find and call the methods by manually typing in the method into the url bar

1 Like

Very cool. Mind sharing one of the URL formats? I’d love to be able to run reports from PowerShell…

Thanks!

Mark W.

api/help/odata/Erp.RPT.StockStatusReportSvc/index

3 Likes

Huh, I was expecting it in the Custom Methods. Thanks!

Mark W

I’m pretty close I think but has anyone had luck posting to the BAQReportSvc method SubmitToAgent?
The part I’m a little hung up on is the where to get and what format to put the Filter1 value as.


Obvjoulsy copying the XML from a trace log isn’t working so well, but I’m not entirely sure what Filter1 is looking for. In an XML trace, this seems to be filling out the BAQReportDataSet, but I’m not sure how to get it into this call…

So that’s a “Serialization” of the DynamicReport data-set… its gonna be tough to get that through JSON…
in C# I do a GetByID on the dynamicReportImpl BO then update the BAQRptOptionFlds (set the options) then use a StringWriter to serialize the rptDS.WriteXML then set that as the value of filter one…

var baqR = WCFServiceSupport.CreateImpl<Ice.Proxy.Rpt.BAQReportImpl>((Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BAQReportSvcContract>.UriPath);
        var dynamicReport = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.DynamicReportImpl>((Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.DynamicReportSvcContract>.UriPath);
        var rptMonitor = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.ReportMonitorImpl>((Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.ReportMonitorSvcContract>.UriPath);
        var rptDs = dynamicReport.GetByID("EDI870EXPORT");
        var baqRptDS = baqR.GetNewBAQReportParam("EDI870EXPORT");
        baqRptDS.BAQReportParam[0].Option01 = guid.ToString();
        baqRptDS.BAQReportParam[0].AutoAction="SSRSGenerate";
        baqRptDS.BAQReportParam[0].SSRSRenderFormat = "CSV";
        baqRptDS.BAQReportParam[0].Character01=guid.ToString();
        baqRptDS.BAQReportParam[0].Character02=flag;
        baqRptDS.BAQReportParam[0].BAQRptID="EDI870EXPORT";
        baqRptDS.BAQReportParam[0].ReportID="EDI870EXPORT";
        baqRptDS.BAQReportParam[0].Summary = false;
        baqRptDS.BAQReportParam[0].ReportStyleNum = 1002;
        baqRptDS.BAQReportParam[0].BAQID="FAM-EDI870-DASHBOARD";
        baqRptDS.BAQReportParam[0].ReportTitle = "EDI 870 Export";
        baqRptDS.BAQReportParam[0].TaskNote = guid.ToString();
        rptDs.BAQRptOptionFld[0].FieldValue = guid.ToString();
     
        rptDs.AcceptChanges();
        StringWriter writer = new StringWriter();
        rptDs.WriteXml(writer);
        baqRptDS.BAQReportParam[0].Filter1 = writer.ToString();
        baqR.RunDirect(baqRptDS);
1 Like

I personally run reports all day in REST by Using UBAQ’s and it is a LOT simpler. Simply Write an Updatable BAQ that takes in the parameters I want to pass. Then I write the C# for running the report in the BPM processing side.
In Rest all i do is call Patch() on my UBAQ

2 Likes

Ah that makes sense. I was thinking about how I might tackle a printing problem that I have with the API, which still might be an option.
I’m thinking about integrating a document envelope type technology (like DocuSign) into the ERP. The problem is that the documents we send are never identical and are always custom report outputs in PDF format.
I need a way to dynamically print the report from the application to a specific location to have the third party software grab the file and consume.

Interesting you bring up uBAQs and I am working on an integration right now with our website and I’m finding them much faster and easier to work with than standard BO methods. I’ll have to take a look at it for this!

1 Like

I use REST Almost exclusively via UBAQs.

1 Like

Does it matter what table the UBAQ is created against? My first though is using a UD table and then basically riding the method call to execute the custom code pre-procesing.

Nope I use Company generally to return just 1 row and then a bunch of calculated fields. Drag Company set the filter to Company = BAQConstant.CurrentComp
Then use Calculated_Filter1, Calculated_ReportStyle, Calculated_etc
Make them all “Updatable” and handle the Update Processing on the BPM Side.

2 Likes

Awesome, thanks!

Sorry to keep digging this one out of the grave.
I have made great progress with the method you’ve demonstrated. Since it was through a BPM, I think I need to use ServiceRenderer rather than WCFServiceSupport. Using that, I was able to get to the point where I am am telling th DynamicReportTableset to “accept changes”, where I then get a “DynamicReportTableset” does not contain a definiton for “AcceptChanges” blah blah blah.


I have a feeling this is probably due to a “Tableset” vs. Dataset issue, but how did you get around that?

It is because of the Tableset, vs DataSAet you should be able to do without the AcceptChanges

Cool, thanks!

Got another one.I can’t serialize the entire table set because IIceTable has no default accessor.

You had demonstrated one method of doing so by serializing each of the underlying tables in the tableset. In this case, if I were to serialize each of the 5 tables, I’m not sure how I might recombine them into the XML format that the filter is expecting. In the example below, it’s writing out to a temp file, but I didn’t see how it might be recombined.

Using XML Serialization wont work because there is no default accesor in IIceTable , however you can serialize the individual tables
as shown below. So you can do this for each of the Tables in the TableSet. (Kinda lame)

Erp.Tablesets.OrderHedTable sods = this.result.OrderHed;
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(sods.GetType());
TextWriter WriteFileStream = new StreamWriter(@“C:\tmp\test.xml”);
x.Serialize(WriteFileStream, sods);
WriteFileStream.Close();

Yuck no that’s ugly… Hmmm… let me poke at it

1 Like

So even on the server side they want to use a DataSet… There’s a converter for this… you can convert a tableset to a dataset. Let me find it

So this will convert the tableset to the dataset… its ugly… but ti should work
add a using

using Ice.BO;
DynamicReportTableset dynRptTs = new DynamicReportTableset(); //You'll have this onelaready
            
DynamicReportDataSet dynRptDs = new DynamicReportDataSet(); //Create this one to serialize

DatasetAdapter.CopyTSTableToDataTable<BAQReportRow, DynamicReportDataSet.BAQReportDataTable>(dynRptTs.BAQReport, dynRptDs.BAQReport);
DatasetAdapter.CopyTSTableToDataTable<BAQRptFilterRow, DynamicReportDataSet.BAQRptFilterDataTable>(dynRptTs.BAQRptFilter, dynRptDs.BAQRptFilter);
DatasetAdapter.CopyTSTableToDataTable<BAQRptOptionFldRow, DynamicReportDataSet.BAQRptOptionFldDataTable>(dynRptTs.BAQRptOptionFld, dynRptDs.BAQRptOptionFld);
DatasetAdapter.CopyTSTableToDataTable<BAQRptSortRow, DynamicReportDataSet.BAQRptSortDataTable>(dynRptTs.BAQRptSort, dynRptDs.BAQRptSort);
DatasetAdapter.CopyTSTableToDataTable<BAQRptSortFldRow, DynamicReportDataSet.BAQRptSortFldDataTable>(dynRptTs.BAQRptSortFld, dynRptDs.BAQRptSortFld);
4 Likes