In a previous post, I showed how to enable Dynamics 365 SharePoint integration. This allows you to store attachments in SharePoint instead of Dynamics – which is a lot cheaper and allows for better document management.

One of the issues with using SharePoint to store the attachments is that they cannot be shown on Dynamics forms out of the box. This means that the user has to use the navigation menu to see them. In my experience this can cause frustration for the users.

This is an easy fix by using JavaScript and an IFrame on the form. The content of the IFrame is set by JavaScript. In my case, I have also used a separate tab to have the IFrame in. I do this so that I can hide the entire section if there is no associated Document Location.

This idea was originally found on Jason Lattimer’s blog, but I have modified it for my own needs by adding the tab functionality. I have also updated the code to use formContext instead of Xrm.Page to future proof it.

Form Setup

I use the components below on my form. I recommend using the settings in the IFrame to give the cleanest look, but these changeable based on your requirements.

  • Tab
  • IFrame
    • Restrict cross-frame scripting has to be disabled
    • Number of Rows set to 34
    • Scrolling set to Never
    • Display Border disabled

Script Setup

The following script then needs to be added to the on-load event of the Form with the formContext passed as the initial variable & then the tab name and IFrame name following it.

Finished Product

After the form & script have been updated, the documents subgrid should appear on the form as below.

Documents showing in the sub-grid on the main accounts formDocuments showing in a sub-grid on the Accounts Main Form

The post Dynamics 365 – Show SharePoint Documents appeared first on Jason Clair.