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 form
Documents showing in a sub-grid on the Accounts Main Form

This Post Has 9 Comments

  1. Hello Jason!

    I’ve been working on this sharepoint integration on the main form of an entity, and thanks to you I’ve already done it.
    But I have a question, or a little problem, in the classic interface the iframe works well, but in the unified interface the functionality of the buttons of the iframe doesnt work.

    I’ve seen that the automatically integrated relation to the documents of sharepoint, has an iframe but in unified interface, but I don’t know how to get this, iframe, on the main form of the UI. Can you give me an advice?

    If I’m not clear, pls feel free to ask.

    Best regards. Joe.

    1. Hi Joe,

      I’ve not had a look at this functionality in Unified Interface in much detail yet, but I have seen a question on the Dynamics community forums where the poster suggests that it no longer works and instead links to a blog post about embedding canvas apps which may be worth checking out.

      Hope this helps 🙂

  2. Have you ever had a request to link directly to the document within SP? My client wants to either A. see the grid containing multiple documents or B. link directly to the document if there is only a single document in the SP library.

    1. Hi Michelle,

      I’ve not had a request like this yet. If you’re using Unified Interface then the blog post about embedded canvas apps may help, it shows how to use embedded canvas apps to display a grid of documents, with some modification you may be able to achieve your requirement.

      I’d be interested to hear how this goes 🙂

  3. Struggling to find understand what URL you enter for the iframe? Can anyone help?

    1. Hi James,

      Do you mean when you’re setting up the iframe? If so, I just use a readily accessible site like


  4. Thanks Jason

Leave a Reply

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

Close Menu
%d bloggers like this: