You think this ‘hard way’ can be done within an Epicor Function? Also, we’re cloud-based, for what its worth - in terms of DLLs, etc.
Did it yesterday, all SaaS and sass here.
There’s also a ReportStyleRow in addition to the ParameterRow that is submitted to the agent. The report style row has the following fields:
Also I have a BO on here somewhere for overriding report naming.
Not sure if it will affect attachment name.
That may be worth a try. I’ll look it up.
You may can do the above, or I can show or find you an example of run direct and then attach.
Reading it now. This looks promising! I’ll test it out and post the results shortly.
Its not clear to me what your context is, but from one of my own apps I use Run Direct and then download the report with a BAQ:
private static bool TryDownloadingJobSSRS(string jobNum, int numCopies, string reportStyleID, string printerName, string suffix)
{
var reportGUID = Guid.NewGuid().ToString();
var pData = new
{
ds = new
{
JobTravParam = new[]
{
new
{
PrntAllMassPrnt = false,
Jobs = jobNum,
Assembly = "0",
ReportStyleNum = reportStyleID,
AutoAction = "SSRSPREVIEW",
SSRSRenderFormat = "PDF",
TaskNote = reportGUID,
ShpSchd = true,
BarCodes = true,
},
},
},
};
var pdfFileName = $@"{Settings.Default.TempPDFLocation}{jobNum}{suffix}.pdf";
EpicorRest.DynamicPost("Erp.RPT.JobTravSvc", "RunDirect", pData);
if (EpicorRest.LastCallResult != System.Net.HttpStatusCode.OK)
{
Log.Error($"[{jobNum}] FAILED TO GENERATE REPORT. See error:");
Log.Error(EpicorRest.LastCallErrorMessage);
critialErrors += 1;
return false;
}
var reports = EpicorRest.DynamicGet("BaqSvc", "Production-DownloadTravRpt", new Dictionary<string, string>() { { "GUID", reportGUID } });
if (EpicorRest.LastCallResult != System.Net.HttpStatusCode.OK)
{
Log.Error($"[{jobNum}] FAILED TO DOWNLOAD REPORT. See error:");
Log.Error(EpicorRest.LastCallErrorMessage);
critialErrors += 1;
return false;
}
else if (reports["value"].Count <= 0)
{
Log.Error($"[{jobNum}] ERROR: BAQ 'Production-DownloadTravRpt' returned no results, so no report could be downloaded.");
critialErrors += 1;
return false;
}
try
{
File.WriteAllBytes(pdfFileName, Convert.FromBase64String(reports["value"].Last.SysRptLst_RptData.ToString()));
return true;
}
catch (Exception e)
{
Log.Error($"[{jobNum}]: Could not save report pdf. File path: {pdfFileName}");
Log.Error($"[{jobNum}]: Error: {e}");
critialErrors += 1;
return false;
}
}
that’s the spirit!
Perfect example.
Thanks Evan. You’re able to write to the server? Is that what I’m seeing in the File.WriteAllBytes section?
That code actually isn’t running from the server, but I believe there is a location you can write to. If you are writing your own program, or if you are in a customization you can do it the way I did.
If you are in an Epicor function, you can call Run Direct like any other BO, get the reports bytes with a BAQ (BAQ in function again by @klincecum), then you could use @klincecum 's Emailer function and pass it the attachment file name and bytes.
Whew! Okay. Thanks.
Lots of stuff to work through. I appreciate the feedback!
Its not too bad, if nobody else does it before me I can get you a more complete example but I am trying to work right now haha
Great job y’all! @Andrew don’t forget to mark a solution to whatever post gets you the furthest and if you feel like posting your final solution that is always awesome too.
Absolutely. Thanks to all for your input. Again, I’ll post results as soon as I’m done testing. I’ve been told that Utah will be providing chicken!
Haha where are all y’all at… we need to find a middle point. Bayou would be fine by me though.
Connecticut!
@Evan_Purdy is in NY I believe so @klincecum you’re gonna have to come north for some chicken. Let me put that kindly… would you consider coming north?
we could all meet in St. Louis or somewhere in TN or something.
Do y’all even know how to cook chicken?