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

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.

Hey Adam,

I got rid of the " characters and it worked.

Once again, you have amazed me with your expertise and willingness to help me in a very timely manner. I don’t know what I would do without you.

Thank You !!!
Richard

1 Like

Hey Adam,

I have a new twist to calling a BAQ report from BPM data directive using c# code. Instead of calling a BAQ report, I want to call a Epicor report, specifically RcvLabel. Below is the trace when I run it from Receipt Entry, Actions, Print Label.

Please Help!
Thanks,
Richard















































Sorry, here is my trace.uploadtrace.txt (6.1 KB)

Nevermind Adam,

I figured it out, see below. After adding the RcvLabel reference and substituting baqreport with RcvLabel I go it to work! With a little education and a lot of help from you, I think that everything is now falling in place for me.

Thanks,
RIchard

try
{
 using (Ice.Contracts.DynamicReportSvcContract dynamicReport = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.DynamicReportSvcContract>(Db))
 {
   using( Erp.Contracts.RcvLabelSvcContract RcvLabel = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.RcvLabelSvcContract>(Db) )
   {

     var baqRptDS = RcvLabel.GetNewParameters();

     baqRptDS.RcvLabelParam[0].AutoAction = ppmode;
     baqRptDS.RcvLabelParam[0].PrinterName = prtername;
     baqRptDS.RcvLabelParam[0].WorkstationID = workstationid;
     baqRptDS.RcvLabelParam[0].SSRSRenderFormat = pdfemf;
     baqRptDS.RcvLabelParam[0].AttachmentType = pdfemf;
     baqRptDS.RcvLabelParam[0].RecurringTask = false;
     baqRptDS.RcvLabelParam[0].SSRSEnableRouting = false;
     baqRptDS.RcvLabelParam[0].ArchiveCode = 0;
     baqRptDS.RcvLabelParam[0].AgentSchedNum = 0;
     baqRptDS.RcvLabelParam[0].AgentID = "DefaultTaskAgent";
     baqRptDS.RcvLabelParam[0].ReportStyleNum = 1001;
     baqRptDS.RcvLabelParam[0].VendorNum = ttRcvDtlRow.VendorNum;
     baqRptDS.RcvLabelParam[0].PurPoint = ttRcvDtlRow.PurPoint;
     baqRptDS.RcvLabelParam[0].PackSlip = ttRcvDtlRow.PackSlip;
     baqRptDS.RcvLabelParam[0].PackLine = ttRcvDtlRow.PackLine;
     baqRptDS.RcvLabelParam[0].PrintAll = false;
     baqRptDS.RcvLabelParam[0].AgentTaskNum = 0;
baqRptDS.RcvLabelParam[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]";       
baqRptDS.RcvLabelParam[0].RowMod = "A";

     RcvLabel.SubmitToAgent(baqRptDS, "DefaultTaskAgent", 0, 0, "Erp.Rpt.RcvLabel;RcvLabel");
   }
 }
}

Printing a report from a data directive is akin to use a cannon to kill a mosquito. It’ll probably work but it’s a bad idea
Data directives are basically database triggers and as such they are meant to be very very fast

I would recommend you look at moving this to a method directive or an async function call or something else for performance sake

1 Like

There definitely seems to be some crossover between bpm and form customizations in this thread, but it seems that the code is still working for some in a BPM.

I’m not sure if it’s the version I’m using . but I can’t access the objects as a DataSet, but rather the svc contracts are resulting in a Tableset instead.

Everything else seems good, but my xml filter keeps failing and System Monitor shows an error.

My xml looks good though using Newtonsoft to conver to a JObject and then to XML.

Any ideas?

It seems as though the problem was that I was encoding the xml since the trace appears to. I don’t think the c# calls want encoded xml.

There should not be any xml at all

Open a new topic with whatever you are trying to do plz this thread is old and dead