Render report to memory stream D365 (aka AX7)

Recently I was tasked with an upgrade of a functionality we have on AX2012 to Dynamics365, which includes running the report from the code and attaching it to the caller record. As you are probably aware of, this was very easy to accomplish in the earlier Microsoft Dynamics AX versions, where you could simply run the report to a file, save it locally and attach it to the record using the DocuActionArchive class.

Things are a bit more complicated when it comes to D365 in cloud. You are no longer able to save the file locally (for example using System.IO.Path::GetTempPath() + fileName) as storage is now moved to Azure and files are stored as a Blob. You may have also noticed that most of the classes that work with files now use stream objects with their content type instead.

In order to attach the report to a record I needed to provide a MemoryStream object which would represent my report. As I found no existing code that could provide me with the memory stream output of the report I created my own method to do this. Below is given a code (runnable class – job) to perform rendering of a report to a memory stream.


Continue Reading

End of content

No more pages to load