How to call a BAQ report from BPM data directive using c# code

Here’s the additional references I have:

image

image

Most of the “does not exist in the current context” errors relate to my variables. I initiated them outside the code block in ‘set field’ widgets using values passed from a customization, so you would need to create new ones or pass in hard text values.

Richard
Printing a report directly from a data directive is a Horrendous idea. Data Directives are a giant hammer and running a report takes a LONG time this is going to bring your epicor to its knees.

can I ask why you need to do this at a Data Directive Level? (what is the end goal)

Have you looked into Auto Print?

Adam, Thank you for your additional usings.

Jose,
My end goal is to print a BAQ report to a local printer on each Mes computer which uses the same Epicor user name without doing a preview to pdf because the printers are label printers and I do not want the Mes user to have to click on the pdf to send it to the label printer. I am currently using the auto print in a BPM data directive on labordtl change with qty complete produce the label to print but the user has to do the pdf to printer thing each time they do an end activity which takes too much time. I know that Epicor prints directly to a label printer when the Mes user clicks Print Tags on the end activity form even though each MES user uses the same user name but I don’t know how?
Any information would be helpful.
Thanks,
Richard

If you are printing labels, I would really look into bartender. It works way better than ssrs to print to label printers, and you can bypass ssrs altogether of you want.

1 Like

Hey Adam,

Thank you for your response. I understand everything about the variables needing to be set by me. I do not understand why I am getting the below error 6 times in your code?

Please help !!!
Thanks,
Richard

|CS0246|The type or namespace name ‘DynamicReportDataSet’ could not be found (are you missing a using directive or an assembly reference?)|

I’m not sure, did you add the using Ice.BO? That portion of the code was from this post:

Hey Adam,

Thank you for your response.

I forgot the ; after the using Ice.BO. I put the ; in and that fixed the problem.

Now I am able to run it but I get the error:

An error occurred trying to print report. Invalid AgentID.

You have “Main” as the agent id?

Any ideas?

Thanks,
Richard

Check System Agent Maintenance for the agent ID.

Hey Adam,

Thank you for your response.

I got it working by using a value in quotes for the workstationid that I got from a trace from my test computer. Amazing!

I have been trying to figure out how to get the workstationid from a customization in a form in c# but have struck out.

Would you please give me your c# code from your customization to get the workstationid and then I will try to figure out how to transfer it from the customization to my BPM via bpmcontextdata.

Thanks,
Richard

Hey Richard,

Good to hear. I used

EpiDataView callContextBpm = (EpiDataView)(oTrans.EpiDataViews["CallContextBpmData"]);
System.Data.DataRow callContextBpmRow = callContextBpm.CurrentDataRow;
callContextBpmRow.BeginEdit();
callContextBpmRow["Character02"] = Ice.Lib.Report.EpiReportFunctions.GetWorkStationID((Ice.Core.Session)oTrans.Session);
callContextBpmRow.EndEdit();

in a customization. You can get the workstation in the data directive too:

Looks like you’re trying to print labels. Have you looked into BarTender? For what it can do, easy of use, flexibility, and integrability it’s dirt cheap. And I’m a cheap A-Hole ask @josecgomez he loves to remind me of that.

just this part :stuck_out_tongue:

Hey Adam,

OMFG, I can’t believe that you gave me the answers to my questions and allowed me to solve my problem. I have been working on this for over a year. I really did not think it was possible to do what you helped me do. You are amazing. What you did is worth a million dollars to me.

Besides me giving you a million dollars, what can I do to return this favor?

Thanks,
Richard

1 Like

Hey Richard,

Glad I could help!

Your flattery is more than enough to return the favor :wink:

1 Like

I finally tested the label print direct to a label printer using SSRSCLIENTPRINT as PDF and it prints teeny, tiny. If I print it using SSRSPREVIEW and print it on regular paper or print to the label printer after previewing, it prints correctly. What am I doing wrong?

Please help!!!

Thanks,
Richard

image

It could be related to the printer/page settings being passed with the SubmitToAgent call. I passed those to the BPM from a customization, here’s the code I used in the customization:

using Ice.Lib.Report;
using System.Text.RegularExpressions;
using System.Drawing.Printing;

PrinterSettings printerSettings =  new PrinterSettings(); //pulls in printer settings from printers installed on client
String labelPrinter = "";
for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++){ //loop through installed printers to find zebra label printer
	bool isZebraPrinter = Regex.IsMatch(PrinterSettings.InstalledPrinters[i], ".*ZDesigner.*" , RegexOptions.IgnoreCase ); //check for zebra printer
	if(isZebraPrinter){
    labelPrinter = PrinterSettings.InstalledPrinters[i]; //set printer name when printer is matched/found
    break;
	}
}
EpiDataView callContextBpm = (EpiDataView)(oTrans.EpiDataViews["CallContextBpmData"]); //set up callContextBpm data to pass to BPM
System.Data.DataRow callContextBpmRow = callContextBpm.CurrentDataRow;
if ((callContextBpmRow != null)){
  callContextBpmRow.BeginEdit();
  if(labelPrinter != ""){
    printerSettings.PrinterName = labelPrinter; //set the printerSetting's printerName. This is analagous to selecting a printer; the settings for this printer name gets passed to the BPM
    callContextBpmRow["Character01"] = printerSettings.PrinterName; //set the printer name, printer settings, and page settings
    callContextBpmRow["Character03"] = EpiPageSettings.FromPageSettings(printerSettings.DefaultPageSettings).Serialize();
    callContextBpmRow["Character04"] = EpiPrinterSettings.FromPrinterSetting(printerSettings).Serialize();
  }			
  else {
    callContextBpmRow["Character01"] = "No Printer Found";
  }
  callContextBpmRow.EndEdit();
}

Hey Adam,

Thank you for your reply.

I get 2 errors after I put your new code into my customization.

Error: CS0103 - line 74 (490) - The name ‘EpiPageSettings’ does not exist in the current context
Error: CS0103 - line 75 (491) - The name ‘EpiPrinterSettings’ does not exist in the current context

I have these usings:
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Ice.Lib.Report;
using System.Text.RegularExpressions;
using System.Drawing.Printing;

Thanks,
Richard

Hey Richard,

Forgot I had this Custom Assembly Reference added:

image

Hey Adam,

Thank you for you reply.

I added this line to my BPM:
baqRptDS.BAQReportParam[0].RptPageSettings = “Color=False,Landscape=False,PaperSize=[Kind=“Custom” PaperName=“Custom” Height=600 Width=400],PaperSource=[SourceName=“Manual feed” Kind=“Manual”],PrinterResolution=[Kind=“Custom” X=203 Y=203]”;

When I did a check syntax, I got these errors. Without this line I get syntax ok.
Thanks,
Richard

||CS1002|; expected|
||CS1002|; expected|
||CS1002|; expected|
||CS1002|; expected|
||CS1002|; expected|
||CS1002|; expected|
||CS1002|; expected|
||CS1002|; expected|
||CS1002|; expected|
||CS1002|; expected|
||CS0103|The name ‘Custom’ does not exist in the current context|
||CS0103|The name ‘Custom’ does not exist in the current context|
||CS0246|The type or namespace name ‘Manual’ could not be found (are you missing a using directive or an assembly reference?)|
||CS0103|The name ‘Manual’ does not exist in the current context|
||CS0103|The name ‘Custom’ does not exist in the current context|
||CS0201|Only assignment, call, increment, decrement, and new object expressions can be used as a statement|

I think it’s related to the " characters in the string.