I have come across a couple of different posts that give code samples of how to print preview or print an SSRS report from a customization. The problem that I believe I am having though is that they utilize Windows Communication Foundation (WCF) services which is no longer supported as of Kinetic 2022.1. We are a hosted cloud customer and as of this posting we are running Kinetic 2022.2.8. The original Topic that I linked this new one off of is what I was using for reference until I realized that WFC is no longer supported and those are the lines of code that are erroring out on me. I have a customization on the UD107 entry form. I am using the Classic form not a Kinetic form.
Continuing the discussion from Printing SSRS from c# customization:
BPM is going to be your best option.
You can print/preview/email reports using a standard BPM widget. Believe itās available in Post Processing Method Directives and Standard Data Directives.
A screen customization could be used in conjunction with this but would not be necessary. For instance you might want to add a UD checkbox to the screen and use it as your print condition in the BPM.
just what I was going to say. Weāve re-enabled WCF using the script that ships with 2022.1 but itās going away soon.
Thanks for the quick reply. What you are describing is similar to the approach that I was originally taking. I was not using a BPM though because I was not able to find a widget for printing reports in Post-Processing. I was able to locate the āAuto Printā widget in the Standard data directive though. The problem there though was that I did not have a way to activate the directive that I created. I had my customization setting a field that the directive could evaluate in a condition but I didnāt know of a way to initiate the directive so it could check the condition on that field because simply pressing the print button doesnāt cause a data update or addition that the directive could react to.
Right now I have a Print icon that I have added to the UD107 formās toolbar and what I would like to do is launch a print preview of my report when someone clicks that icon.
Iāve done it in Kinetic, and in classic without WCF. Iāll post some examples later on this weekend if someone doesnāt beat me to itā¦
Thank you thatād be much appreciated.
Thatās good to hear. Where did you get the script, is it on EpicWeb?
just have the print button update a checkbox field. Have the BPM check if the box changes from any to another
search this forum or the customization guides. After you install kinetic, thereās a .sql file in a fairly top level folder where you enter the service for which you want to re-enable WCF, and then run on your DB.
Obviously in dev first, but I used it on a. dozen services or so without any issues.
I have done it in a classic forms, without WCF, but since we are moving forwardā¦
Even if you are using the classic forms, I would do the code in a BPM, and I would
probably closely follow @zwilli526 suggestion.
That way when you want to do it later in Kinetic, it will already be built and ready.
Just wanted to double check. The link you provided is speaking of a BAQ Report. Are you wanting a regular Epicor SSRS report? Or are you looking at a BAQ report?
I guess thatās where maybe I am misunderstanding how print buttons work on in other areas of Epicor. It doesnāt seem like the correct approach to print something would be to save a change to a record every time that I want to print something out. I havenāt done a trace on one of the system print buttons though so, for all I know that is how these requests are handled.
@klincecum
I am very in favor of this idea but I donāt have a way around the above issue. If I did want to initiate an update on the record to initiate a directive how would that work?
The two scenarios that I can think of are:
- That a user would hit the print button and that would set my checkbox. Then I would have to perform an update call via the customization. This might negate the upgradeability benefit of the directive approach.
- I could also just set the box and the next time the record is saved the print preview would fire. This is not a reliable sequence of user events.
Iām sure there are other scenarios besides these two I am just not able to come up with them on my own at this time.
It is a BAQ Report that I am using to generate an SSRS report. Sorry I should have clarified that.
Here is an example in the classic form (assuming 1 parameter on the BAQ):
private void PrintBAQSSRS(string baqReportName, string baqID, string param1)
{
string agentID = "";
try
{
Session otSession = (Session)oTrans.Session;
//Set the workstationID
string workStation = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID(otSession);
//Get or Set the AgentID
using (var aSA = new SysAgentAdapter(oTrans))
{
aSA.BOConnect();
aSA.GetDefaultTaskAgentID(out agentID);
if (!string.IsNullOrEmpty(agentID)) { agentID = "SystemTaskAgent"; }
}
var baqReport = new Ice.Lib.Adapters.BAQReportAdapter(oTrans);
baqReport.BOConnect();
var dynamicReport = new DynamicReportAdapter(oTrans);
dynamicReport.BOConnect();
dynamicReport.GetByID(baqReportName);
// GET DEFAULT REPORT PARAMETERS
baqReport.GetNewBAQReportParam(baqReportName);
baqReport.ReportDataSet.BAQReportParam[0].Option01 = param1;
baqReport.ReportDataSet.BAQReportParam[0].AutoAction = "SSRSPREVIEW";
baqReport.ReportDataSet.BAQReportParam[0].WorkstationID = workStation;
baqReport.ReportDataSet.BAQReportParam[0].SSRSRenderFormat = "PDF";
baqReport.ReportDataSet.BAQReportParam[0].BAQRptID = baqReportName;
baqReport.ReportDataSet.BAQReportParam[0].ReportID = baqReportName;
baqReport.ReportDataSet.BAQReportParam[0].Summary = false;
baqReport.ReportDataSet.BAQReportParam[0].ReportStyleNum = 1;
baqReport.ReportDataSet.BAQReportParam[0].BAQID = baqID;
dynamicReport.DynamicReportData.BAQRptOptionFld[0].FieldValue = param1;
dynamicReport.DynamicReportData.AcceptChanges();
StringWriter writer = new StringWriter();
dynamicReport.DynamicReportData.WriteXml(writer);
baqReport.ReportDataSet.BAQReportParam[0].Filter1 = writer.ToString();
baqReport.SubmitToAgent(agentID, 0, 0, "Erp.UIRpt.BAQReport");
}
catch (Exception ex)
{
MessageBox.Show("An error occured trying to print report." + ex.Message);
}
}
I am getting this Error when I try to compile:
The type or namespace name āBAQReportAdapterā does not exist in the namespace āIce.Lib.Adaptersā (are you missing an assembly reference?)
I am not seeing an adapter in the Object Explorer or a dll in the assembly reference manager. I have had this issue with other references in the past and then I stumble across them eventually so, I will keep looking.
Do you know if there is a user or help guide that describes the different adapters and their parameters?
Make sure you have these two added to your references:
You print from a UBAQ BPM if you want to do it ad-hoc.
Call the Dynamic Query Adapter, use a custom action.
Or create a function and do it there.
Personally I prefer to follow Epicor.
I create a BAQ Report and that comes with its own Menu item called āPrint UD Formā example. Then my UD Form will use LaunchForm to launch the Printing Form, that way I honor printer selection, routing rules, filters, various report styles among other things.
Now you can print it via the UD Form but also as a standalone option under a Reports Menu Folder.
You can pass in via LFO filtersā¦ so when you launch it you fill out a filter for example āOrder: 19929ā so all they do is hit Print.
Wouldnāt this still require using a customization? or maybe I am not understanding what you mean by ācustom actionā.
I havenāt created any functions yet in Epicor so that wouldnāt really be an option for me at this time. That is definitely something on my list of things to learn.
Thank you for your help this worked for me.