If you’re working with the (not so) new self-service Tier 2 environments in Dynamics 365 for Finance and Operations you might have already noticed this: the reports in Tier 2+ and production environments aren’t using the SSRS report viewer, instead they’re being displayed in a beautiful PDF preview form.

But what happens on your development box?

If you want to know more about self-service environments you can read these posts I wrote a while back:

Report viewer on your Dev VM

If you try to print a report from your dev VM/OneBox, you will still see the old HTML SSRS report viewer instead of the self-service preview PDF viewer. This is totally expected and well documented.

But why should I care about this?

To me the reason is one and only one: the way the SSRS report is rendered in the HTML viewer and the PDF preview is different, and sometimes REALLY different. And this can be a problem.

Imagine this: it’s Monday, a new week starts, you’re fresh and full of energy, and you’re the lucky one in the team that got assigned a new report! “Wow, that’s a nice way to start the week” says NOBODY.

Me when I'm assigned a SSRS report
Me when I’m assigned a SSRS report

Sorry, I had to let this go. So you spend many hours changing a report, previewing it, checking that all the 40 damn fields of the line won’t cause a page break, and done. You check it in and the next day somebody tells you that, on UAT, data is being printed in 2 separate pages. Whyyyy?

Well, that’s because the SSRS and PDF viewers don’t render the report the same way. It should be pretty much the same but in the end it’s not.

Fixing your dev box

As I said earlier this is well documented, but when we got into the private self-service preview it wasn’t. Hopefully my colleague Ferni Tudela found that in the SrsReportRunUtil class there was a method that checked if the current environment was self-service:

/// <summary>
    /// Gets if the current environment is a service fabric host environment
    /// </summary>
    /// <returns>True, if the current environment is a service fabric host environment; otherwise, False.</returns>
    public static boolean isServicFabricHostingEnvironment()
    {
        #define.HostingEnvironmentKey("HostingEnvironment")
        var hostingEnvironment = HostingEnvironment::Unknown;
        SysGlobalCache globalCache = classfactory.globalCache();
        try
        {
            // Read from global cache first.
            if(globalCache.isSet(funcname(), #HostingEnvironmentKey))
            {
                hostingEnvironment = globalCache.get(funcname(), #HostingEnvironmentKey);
            }
            else
            {
                var environment = EnvironmentFactory::GetApplicationEnvironment();
                if(environment)
                {
                    // Update global cache.
                    hostingEnvironment = environment.Common.HostingEnvironment;
                    globalCache.set(funcname(), #HostingEnvironmentKey, hostingEnvironment);
                }
            }
        }
        catch (Exception::CLRError)
        {
            hostingEnvironment = HostingEnvironment::Unknown;
        }
        return hostingEnvironment == HostingEnvironment::ServiceFabric;
    }

A workaround was to extend this method and return always true and your dev box would become a fake service fabric VM.

But now there’s a better way to do this, simply navigate to your environment URL and append &mi=SysReportAdministration to it. This will open the report options form where you need to enable the first checkbox:

Report options
Report options

Restart IIS and you’re ready to start using the new PDF preview viewer. I hope this will save some time if you’ve been assigned a report.

Subscribe!

Receive an email when a new post is published
Author

Microsoft Dynamics 365 Finance & Operations technical architect and developer. Business Applications MVP since 2020.

Write A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

ariste.info