web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

Create temp file and send email.

(0) ShareShare
ReportReport
Posted on by 231

I have a request to so create a customer statement and send to the customer in the background.

I am trying to create the PDF file using extensions, but I can;t seem to be able to use any file commands on AL code.

When I try the following command it tells me that TemporaryPath() can not be used in extension development.
Any ideas on how I can create a temporary file to attach to an email via extension ??
filepath:=TEMPORARYPATH() +Filename;
Categories:
  • Suggested answer
    Suresh Kulla Profile Picture
    50,280 Super User 2026 Season 1 on at

    Do something like this

    DestinationFilePath := FileManagement.GetDirectoryName(FileManagement.ServerTempFileName(''));

           DestinationFilePath := DelChr(DestinationFilePath, '>', '\');

           DestinationFilePath += '\';

           case DocumentHeaderRef.Number of

               DATABASE::"Sales Invoice Header":

                   begin

                       DocumentHeaderRef.SetTable(SalesInvoiceHeader);

                       SalesInvoiceHeader.SetRecFilter;

                       DestinationFilePath += SalesInvoiceHeader."No." + '.pdf';

                       REPORT.SaveAsPdf(ReportNo, DestinationFilePath, SalesInvoiceHeader);

                   end;

  • Armela Kamenica Profile Picture
    231 on at

    I can't use

    FileManagement.ServerTempFileName('')

    in Extension development. I tried that and I get an error on my al file.

    Thanks

  • Suggested answer
    Suresh Kulla Profile Picture
    50,280 Super User 2026 Season 1 on at

    If you are creating it for Saas version use the Blob Export command in the File Management

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans