Question

Report Rendered Sometimes Empty


Userlevel 3
Badge +1

I am trying to render a report and then email it. It is created two ways, one on demand and the other in the background. Both methods work fine on my test instance, however in production the background method almost always returns an empty report. My assumption is that the report is missing a context or there is some race condition, but I am not sure.

To be clear the report is generated, with a title and other fixed fields populated, however with zero data fields populated.

The background method is kicked off by a business event, I do have some PXTrace statements in my functions, however they don’t seem to produce results when the function is called from a business event, is this normal? The PXTrace is visible in the profiler when the action is executed by button press.

Below is the function that creates the report, uploads it and then attaches it to the email.

Any direction would be helpful at this point I have tried a lot of different things.

        protected static void _addTaskOrders(PXGraph graph, PMTask task, CREmailActivityMaint emailMaint, CRSMEmail email, IReportLoaderService reportLoader, IReportRenderer reportRenderer, bool noCost)
{
var prj = PMProject.PK.Find(graph, task.ProjectID);

PXTrace.WriteInformation($"Prj {prj.ContractCD} Tsk {task.TaskCD}");

Dictionary<String, String> parameters = new Dictionary<String, String>();
// parameters.Add("TaskID", task.TaskID.ToString());
parameters.Add("Project", prj.ContractCD.Trim());
parameters.Add("Task", task.TaskCD.Trim());
parameters.Add("View", noCost ? "No Cost" : "Internal");// Internal");

Report _report = reportLoader.LoadReport("GP603010", null);
reportLoader.InitDefaultReportParameters(_report, parameters);

byte[] fileData;

using (StreamManager streamMgr = new StreamManager())
{
reportRenderer.Render(RenderType.FilterPdf, _report, deviceInfo: null, streamMgr);
fileData = streamMgr.MainStream.GetBytes();
}

var fileName = $"{prj.ContractCD} - {task.TaskCD.Trim()}.pdf";
var fileInfo = new PX.SM.FileInfo(Guid.NewGuid(), fileName, null, fileData);
// Save file to database
var uploadFileGraph = PXGraph.CreateInstance<UploadFileMaintenance>();
uploadFileGraph.SaveFile(fileInfo, FileExistsAction.CreateVersion);

// Attach file to the dedicated table
PXNoteAttribute.SetFileNotes(emailMaint.Caches[typeof(CRSMEmail)], email, fileInfo.UID.Value);
uploadFileGraph.Persist();
}

 


3 replies

Userlevel 3
Badge

Is there any restriction group you set for your site?

Userlevel 3
Badge +1

No group restrictions.

Userlevel 7
Badge

Hi @Leif were you able to find a solution? Thank you!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved