Hi
I’ve got the following code working, by taking examples from the forum and then using BL Tester and looking at the .dll to work out the relevant method calls and properties. It works, but it’s not dynamic because I can’t work out the XML bit for UserCriteria.
Working Code - but static
private void RunCOAReport(string orderNum)
{
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";
}
}
//MessageBox.Show(agentID + ", " + workStation);
var dynamicCriteriaReport = WCFServiceSupport.CreateImpl<Ice.Proxy.Rpt.DynamicCriteriaImpl>((Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.DynamicCriteriaSvcContract>.UriPath);
var rptParams = dynamicCriteriaReport.GetNewDynamicCriteriaReportParam("COAReport");
rptParams.DynamicCriteriaParam[0].AutoAction = "SSRSPREVIEW";
rptParams.DynamicCriteriaParam[0].ReportStyleNum = 1002;
rptParams.DynamicCriteriaParam[0].WorkstationID = workStation;
rptParams.DynamicCriteriaParam[0].SSRSRenderFormat = "PDF";
rptParams.DynamicCriteriaParam[0].SSRSEnableRouting = false;
rptParams.DynamicCriteriaParam[0].UserCriteria = @"<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?> <UICriteria><RptCriteriaSet><Company /><RptDefID>COAReport</RptDefID><RptCriteriaSetID>COAReport</RptCriteriaSetID><Description>COA Report</Description></RptCriteriaSet><RptCriteriaPrompt><PromptID>1</PromptID><PromptValue>168436</PromptValue><IsToken>false</IsToken><PromptName>OrderNumFrom</PromptName><DataType>int</DataType><Label>Order (From)</Label></RptCriteriaPrompt><RptCriteriaPrompt><PromptID>2</PromptID><PromptValue>168436</PromptValue><IsToken>false</IsToken><PromptName>OrderNumTo</PromptName><DataType>int</DataType><Label>Order (To)</Label></RptCriteriaPrompt><RptCriteriaPrompt><PromptID>3</PromptID><PromptValue>2021-03-11T00:00:00</PromptValue><IsToken>false</IsToken><PromptName>ShipDateFrom</PromptName><DataType>datetime</DataType><Label>Ship Date (From)</Label></RptCriteriaPrompt><RptCriteriaPrompt><PromptID>4</PromptID><PromptValue>2021-03-11T00:00:00</PromptValue><IsToken>false</IsToken><PromptName>ShipDateTo</PromptName><DataType>datetime</DataType><Label>Ship Date (To)</Label></RptCriteriaPrompt> </UICriteria>";
rptParams.AcceptChanges();
dynamicCriteriaReport.RunDirect(rptParams);
}
catch (Exception ex)
{
MessageBox.Show("An error occured trying to print report." + ex.Message);
}
}
I’ve seen other code posted by @josecgomez that uses .WriteXML() method, but that seems to be for another report type.
Am I correct in thinking there are at least 3 different report types:
- Standard Reports (each of which have their own reporting DLL)
- BAQ Reports
- Dynamic Criteria Reports
I haven’t found any examples of people using C# to call Dynamic Criteria reports, so hopefully once my code is complete and working I’ll post the final version!
Thanks!