Showing posts with label Uploading and download file in D365FO. Show all posts
Showing posts with label Uploading and download file in D365FO. Show all posts

Monday, 30 August 2021

Uploading and download file in D365FO

Create a simple form with two buttons file upload & download.

For Upload:

Using button clicked event: File::GetFileFromUser()

For Download:

For Download button: new Browser().navigate(fileUrl).


[Form]

public class SLD_UploadDownload extends FormRun
{
    str fileUrl;
 
    [Control("Button")]
    class UploadButton
    {
        public void clicked()
        {
            FileUploadTemporaryStorageResult result = File::GetFileFromUser() as FileUploadTemporaryStorageResult;
            if (result && result.getUploadStatus())
            {
                fileUrl = result.getDownloadUrl();
                info(fileUrl);
            }
        }
    }
 
    [Control("Button")]
    class DownloadButton
    {
        public void clicked()
        {
            new Browser().navigate(fileUrl);
        }
    }
}

Run AX report using X++

       Args                     args;      ReportRun          report;     salesLineProductPartProd salesLineProductPartProdLocal;     ;     ...