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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

FileUploadTemporaryStorageResult always returns null

(0) ShareShare
ReportReport
Posted on by 10

  pastedimage1625204793763v6.png...pastedimage1625204910100v7.png...pastedimage1625204710114v4.png

Good day. I have a simple upload dialog implemented within my own custom form. Right after browsing, the upload starts. I have put an info just to see if it completes uploading, and it does. Upon clicking "OK", however, fileUploadResult returns null. Here is the code:

[Form]
public class PurchReqUploadFileDialog extends FormRun
{
   FileUploadTemporaryStorageResult fileUploadResult;

   [Control("Custom")]
   class FileUpload1
   {
      public void OnUploadCompleted()
      {
         info(strFmt("Upload Completed"));
         fileUploadResult = this.getFileUploadResult() as FileUploadTemporaryStorageResult;
         super();
      }

   }

   [Control("CommandButton")]
   class OKCommandButton
   {
      public void clicked()
      {
         MenuFunction uploadMenuFunction;
         Args args = new Args();
         super();

         if(fileUploadResult != null && fileUploadResult.getUploadStatus())
         {
            args.parmObject(fileUploadResult);
            uploadMenuFunction = new MenuFunction(identifierStr("MyActionMenuItem"), MenuItemType::Action);
            uploadMenuFunction.run(args);
         }
         else if(fileUploadResult == null) //just to test if this is being the problem, and it is
         {
            info(strFmt("fileuploadresult is null"));
         }
         else
         {
            info(strFmt("fileuploadresult is not null")); //or if getUploadStatus() is the problem
         }
      }

   }

}

As seen in the photos above, fileUploadResult returned null, causing my action menu item that calls a class to not be called. I have initialized and started my AzureStorageEmulator without any problems (as far as I can see. No errors on cmd). I really cannot pinpoint if it were the AzureStorageEmulator that's causing the problem, or if something in this code needs fixing. Do I need to setup anything else regarding the storage emulator other than initializing and starting it? Does my Visual Studio need to be closed while I initialize or start my storage emulator? Any help will be very much appreciated. Thank you!

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: FileUploadTemporaryStorageResult always returns null

    Hi,

    you didn't share the actual logic that uploads the file, or the getFileUploadResult() method, so we can't really tell what could go wrong in those methods.

    You can check how the company logo upload functionality is implemented in Legal entities (CompanyInfo) form. And you can also use it to test if such file upload works in your system.

  • boost Profile Picture
    10 on at
    RE: FileUploadTemporaryStorageResult always returns null

    No sir I did not create the logic that uploads the file. It is integrated within x++. docs.microsoft.com/.../file-upload-control

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: FileUploadTemporaryStorageResult always returns null

    Ok, thanks. Are you sure that you implemented all details?

    What did you learn when you compared it to the Company logo upload (code + functionality)?

  • greengrimms Profile Picture
    1,400 on at
    RE: FileUploadTemporaryStorageResult always returns null

    Hi,

    Just some ideas; what type are you getting from getFileUploadResult() method? Could that conversion you're doing when you assign it to fileUploadResult variable be the cause of the null result?

    Also, if you move the super() to the top on OnUploadCompleted(), do you see any difference?

  • boost Profile Picture
    10 on at
    RE: FileUploadTemporaryStorageResult always returns null

    Yes. I am using multiple code examples as reference and they all pretty much implemented it like that. Even the company logo upload does it in a similar way, except for the fact that they used FileUploadResultBase and not FileUploadTemporaryStorageResult maybe due to the fact that they do need to store it permanently or could be for some other reason (I honestly don't really know they differ). Anyhow, I still tried it on mine and replaced it with FileUploadResultBase and results were the same.

    code snippet from company logo upload:

    public void UploadCompleted()

       {

           FileUpload uploadControl = FileUpload1;

           Array items;

           items = element.args().parmObject();

           FileUploadResultBase uploadResult = uploadControl.getFileUploadResult();

           if (uploadResult && uploadResult.getUploadStatus())   //also tried if(fileUploadResult) instead of if(fileUploadResult != null)

            ...

            ...

            ...

  • boost Profile Picture
    10 on at
    RE: FileUploadTemporaryStorageResult always returns null

    I honestly do not know what kind of data is acquired from the getFileUploadResult() method but pretty much any similar reference I could find online uses it to check if the upload was indeed successful. Also there was no difference when I moved the super() to the top of the function. Anyhow, I have actually managed to solve it by changing the ports to default inside the config file. We were tasked to change that before for a Data Management practice and never changed it back ever since. I had a clue when I tried to export an excel file from All Purchase Orders(which apparently uses AzureStorageEmulator as well), and an error appeared saying something about the ports rejecting it. Anyhow, thank you very much for trying to help. I really appreciate it!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 753

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 752 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 534 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans