Skip to main content
Question

Report Rendered Sometimes Empty


Forum|alt.badge.img+1
  • Varsity I
  • 50 replies

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

Forum|alt.badge.img
  • Jr Varsity I
  • 39 replies
  • May 15, 2024

Is there any restriction group you set for your site?


Forum|alt.badge.img+1
  • Author
  • Varsity I
  • 50 replies
  • May 15, 2024

No group restrictions.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2754 replies
  • July 1, 2024

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings