How to show SharePoint document list on main CRM form

When you enable the SharePoint integration for CRM, you get the ability to view a document list view by navigating to the document area on the form. Often, users want have this list of document available directly on the main form and not have to navigate to another page. Here is one way to do it, applicable for the “old fashion” SharePoint integration using the SharePoint List Component for CRM. It does not apply to server-based SharePoint integration with CRM. This is an unsupported customization, use at your own risk. 

What you need

  • SharePoint integration enabled and configured for the target entity (i.e. list component installed, existing SharePoint Site & folder)
  • an IFrame on the form
  • a way to get the full URL of SharePoint folder associated to your record (could be a field that you automatically populate on the entity with a plugin, could be retrieving the SharePoint Document Location records using JavaScript when for form loads, etc.)

How it works

When the document view is loaded, there is a URL pattern used by the system to display the list component with the documents:

http://sharepointdev/crm/crmgrid/crmgridpage.aspx?langId=en-US&locationUrl={document location url}&pageSize=250

What you can deduct from the URL above:

{SharePoint Root Site}/crmgrid/crmgridpage.aspx?langId={Language}&locationUrl={Document Location Url}&pageSize={Page Size}

Grabbing that Url with the correct parameters and pasting in browser will display the list of document for the target CRM record. In short, all you have to do is display that Url constructed properly inside an iFrame on your CRM form (see illustration below). Please note that this can have a performance impact on how quickly the form loads (this component can take longer to be loaded and displayed.


Code snippet

Javascript Method to load the content

var documentSiteUrl = ""; /* Find a way to get this information – can be read from a hidden field on the form. */
var parentSite = ""; /* Find a way to get this information – can be read from a hidden field on the form. */

if (documentSiteUrl == "" || parentSite == "") {

// Build document location URL - Set IFRAME target
var docViewUrl = parentSite;
if (!StrEndsWith(docViewUrl, "/")) {
   docViewUrl = docViewUrl + "/";

var userLanguage = "en-US";
if (Xrm.Page.context.getUserLcid() == "1036") {
   userLanguage = "fr-FR"

docViewUrl = docViewUrl + "crmgrid/crmgridpage.aspx?langId=" + userLanguage + "&locationUrl=" + documentSiteUrl + "&pageSize=250";

var documentIFrame = Xrm.Page.ui.controls.get("IFRAME_Documents");
if (documentIFrame != null) {
else {

9 thoughts on “How to show SharePoint document list on main CRM form

  1. Hi
    Could you please help me to get the documentSiteUrl and parentSite? What about situation when there is more than one folder per record? also do you know whether this works for CRM Online 2016?
    Thank you very much

    • Hi, you can refer to this link for an idea on how to get the document site URL:
      If you have multiple folders per records, then you probably have to create some custom logic and visual indicator to allow users to navigate from one view to another… All of it very much unsupported though. I don’t believe this will work for CRM 2016 online, it uses Server-to-Server SharePoint integration.

      • Thank you very much for your answer. In the mean time I have managed to get the list of Sharepoint Document Location for particular record (by OData query).

        Now the big issue I find is building the URL for the IFrame. If I pass sharepoint domain link the CORS will block it. How did you deal with it? Is there a way to display the crm document view in this Iframe? I followed this instructions, but in Dynamics 2016 it is pretty uselesss since there are no buttons there (no possibility to add a file) and even clicking on the file name does not cause it to open.

  2. Hi Salim

    How would i customize the iframe itself to add an extra button after the Open Sharepoint Button? And would it be possible to start a sharepoint workflow from the iframe via the new button?

    • Brian, the SharePoint grid is not customization at all. An alternative here would be to write a custom web component to display documents from SharePoint and add more feature. The most cost effective is to have users open SharePoint from CRM and perform SharePoint actions in SP directly.

  3. Hello, nice article but maybe this doesn’t work with the latest sharepoint and v8.2 Dynamics. All is I get is 404 when trying to access Everything looks correct to me. Is the article out of date? Thanks for any help.

    • Andrew the article was written in 2016. Things have changed quite a bit since that time. The grid used by Dynamics is quite different now. I’d be very surprised if this still worked. You’ll have to adapt it by inspecting the new grid’s URL and display that instead.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s