Help needed - saving files on BC SAAS
Not really a bug but wasn't sure where to post this. To migrate a NAV add-on to BC, we need to save documents (reports) as PDF files and then send them out through SMTP mail. We need to specifically name the PDFs (formatted names). On premise this is all easy enough...but how does this work on BC cloud? I think most functions in codeunit 419 are on premise only...correct? Is there a way to use SAVEASPDF on the SAAS version?
Nice question I started working on project to pull files in and was looking to save them as we have in past. Not sure we can do on BC unless we save them a link to a container to store them on.
I found a post outlining how to use SAVEAS to save report output to a stream, and to then use that stream as a PDF email attachment, so that should work. I think the only option for pulling files in would be to store them in BLOB fields within the database. Not great for database size, but the file system seems to be off limits in BC SAAS.
You can use saves as RHansenEpimatic commented. Something like
Table.Reset();
Table.SetRange("No.", DocNo);
RecRef.GetTable(Table);
Clear(TmpBlob);
TmpBlob.Blob.CreateOutStream(outStream1);
if Report.SaveAs(ReportID, '', ReportFormat::Pdf, outStream1, RecRef) then
if TmpBlob.Blob.HasValue() then begin
TmpBlob.Blob.CreateInStream(instream1);
SMTPMail.CreateMessage(SenderName,Sender,Recipients,Subject, Body, IsHTML);
SMTPMail.AddAttachmentStream(instream1, AttachmentName);
SMTPMail.Send();
end;
Thanks for sharing what you found might be the only option we have.