Dear experts, Please suggest how to call BAQ Report on custom button click in script editor.
See the code below:
smith as per your suggestion, we have use the same code in script editor what below error is coming
private void btnReport_Click(object sender, System.EventArgs args)
{
PrintBillsSSRS();
}
private void PrintBillsSSRS()
{
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 objSysAgent = new SysAgentAdapter(oTrans))
{
objSysAgent.BOConnect();
objSysAgent.GetDefaultTaskAgentID(out agentID);
if (!string.IsNullOrEmpty(agentID))
{
agentID = "SystemTaskAgent";
}
}
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);
// GET DEFAULT REPORT PARAMETERS
var rptDs = dynamicReport.GetByID("RptAgdRcv");
var baqRptDS = baqR.GetNewBAQReportParam("RptAgdRcv");
baqRptDS.BAQReportParam[0].Option01 = "20061";
baqRptDS.BAQReportParam[0].AutoAction = "SSRSPREVIEW";
baqRptDS.BAQReportParam[0].WorkstationID = workStation;
baqRptDS.BAQReportParam[0].SSRSRenderFormat = "PDF";
baqRptDS.BAQReportParam[0].BAQRptID = "RptAgdRcv";
baqRptDS.BAQReportParam[0].ReportID = "RptAgdRcv";
baqRptDS.BAQReportParam[0].Summary = false;
baqRptDS.BAQReportParam[0].ReportStyleNum = 1;
baqRptDS.BAQReportParam[0].BAQID = "BAQ_AR_AGED_RECEIVABLE_REPORT";
baqRptDS.BAQReportParam[0].ReportTitle = "Aged Receivable";
rptDs.BAQRptOptionFld[0].FieldValue = 20061;
rptDs.AcceptChanges();
StringWriter writer = new StringWriter();
rptDs.WriteXml(writer);
baqRptDS.BAQReportParam[0].Filter1 = writer.ToString();
baqR.SubmitToAgent(baqRptDS, agentID, 0, 0, "Erp.UIRpt.BAQReport");
}
catch (Exception ex)
{
MessageBox.Show("An error occured trying to print report." + ex.Message);
}
}
You have to add references to Ice.Adapters.DynamicQuery and Ice.Adapters.SysAgent. Then make sure you add a
using Ice.Adapters;