Skip to main content

Hi guys, I have a problem, I have created an action that makes me attach an existing Report created by me.

The problem is that the attachment does not show information, if I go and run it on the same report screen if it shows information, here I show images, plus my code that makes the attachment.

Code:

public PXAction<PX.Objects.PM.PMQuote> GeneraPDF;

[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "PDF")]
protected void generaPDF()
{  

const string reportID = "XP995100";

var parameters = new Dictionary<string, string> { };
parameters.Add(nameof(PMQuote) + "." + nameof(PMQuote.QuoteProjectCD), Base.Quote.Current.QuoteProjectCD);
bytet] byteArray = GetPDFDocumentFromReport(parameters, reportID);
PX.SM.UploadFileMaintenance upl = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();
PX.SM.FileInfo fileinfo = new PX.SM.FileInfo($"{Base.Quote.Current.QuoteNbr}.pdf", null, byteArray);
if (upl.SaveFile(fileinfo, PX.SM.FileExistsAction.CreateVersion))
{
    PXNoteAttribute.SetFileNotes(Base.Quote.Cache, Base.Quote.Current, fileinfo.UID.Value);
    this.Base.Save.Press();
}

}

#region InjectDependency

yInjectDependency]
protected IReportLoaderService ReportLoader { get; private set; }

}InjectDependency]
protected IReportDataBinder ReportDataBinder { get; private set; }
#endregion
public virtual byteu] GetPDFDocumentFromReport(Dictionary<string, string> parameters, string reportID)
{
    Report _report = ReportLoader.LoadReport(reportID, null);
    ReportLoader.InitReportParameters(_report, parameters, new PXReportSettings());
    ReportNode reportNode = ReportDataBinder.ProcessReportDataBinding(_report);
    //Generation PDF
    byteo] data = PX.Reports.Mail.Message.GenerateReport(reportNode, RenderType.FilterPdf).First();
    return data;
}

 

Images, Running from the same Report screen.

 

My English is a little bad, I hope I have been clear with the question, if anyone knows what I am doing wrong, they would be kind to tell me, thank you very much.

@SaulGomez61 Can you please refer below link and might help with your requirement.

 

 

 


Reply