Display SharePoint Documents Sub Grid on the MS Dynamics 365 form

8.6k views Asked by At

I have a requirement to display SharePoint Documents Sub Grid on the MS crm Dynamics 365 Custom Entity Form.

Can anyone let me know, how to achieve this using Supported or unsupported way?

3

There are 3 answers

4
Arun Vinoth-Precog Tech - MVP On

Latest: Recent version has direct OOB customization to achieve this.

Dynamics 365: Related Documents Now Display on Record’s Main Form

Add or remove the SharePoint documents tab to the main form for any table

enter image description here


In short: Server to Server integration approach shows physical documents in crm grid. No need of iframe solution.

Old school List component integration has a limitation, it shows document location crm records in crm grid, so you need iframe solution to show physical docs from Sharepoint.

[Applicable to Server based Integration] - It will show Documents in the grid.

Open an Entity Web form where you want to display SharePoint document library.

  1. Click on the Insert-tab, click on Sub-Grid, specify a name to sub-grid
  2. In “Data Source” section select “Only related Records” from Records dropdown
  3. Select “Document Location (Regarding)” in Entity dropdown
  4. Select “Active Document Location” from Default View section [shown in Below Image]
  5. Click on Set. Click on save then publish the customization

enter image description here

Reference

Update: [Applicable to List component Integration]
Associated view will show what we want but subgrid is not working as expected. Upon research, this is product limitation. Read more

sometimes it is desirable to have an “at a glance” view of documents associated with a record. In order to view the documents in SharePoint that are related to a record, the user must navigate to a related entities area outside of the form. (Similar to Connection, or other related entities)

For most related entities, a sub-grid can be used in the form to display the relationships immediately on the form, but there is no simple workaround for the Documents.

Another alternative is showing Associated view in IFRAME.

EDIT: In latest Dynamics 365, CRM + Sharepoint integration using List component is deprecated. Only way is Server to Server (S2S) based CRM + Sharepoint integration is possible. This S2S approach shows documents in the associated grid & subgrid, not the doc location like in List component. CRM - Sharepoint wrapper taking care of conversion from CRM FetchXML to SP CAML query & give us the result we want.

enter image description here

The great thing about having the documents queried by CRM is that you can create custom views of documents in the same way you would with any other entity in CRM. When using the list component the default view in SharePoint was rendered in the IFRAME meaning that to get new columns you had to have list customisation privileges on SharePoint such that all users would see the changes. With the new server to server integration you can select SharePoint columns to include in your own views and even add in your own filters using the CRM advance find interface.

Read more.

0
Andrius Darulis On

You can find solution here:

You may use the below line of code to set the Iframe url to display the subgrid in iframe:

Xrm.Page.getControl("IFRAME_Documents").setSrc(Xrm.Page.context.getClientUrl() + "/userdefined/areas.aspx?formid=" + CurrentFormId + "&inlineEdit=1&navItemName=Documents&oId=%7b" + recordId + "%7d&oType=" + oTypeCode + "&pagemode=iframe&rof=true&security=852023&tabSet=areaSPDocuments&theme=Outlook15White");

Where:

“IFRAME_Documents” is the Iframe name.

“CurrentFormId”= Is the Current selected form id which you can get using Xrm.Page.ui.formSelector.getCurrentItem().getId().replace("{", "").replace("}", "");

“recordId” = Record’s GUID

“oTypeCode” = Entity Type Code which you can get using Xrm.Page.context.getQueryStringParameters().etc;

0
RayS On

This is how I did in D365. (Using Chrome made it easier)

  1. Enable document management for the entity

  2. When Documents tab shows for the entity record open it.

  3. Then open Chrome dev console (F12)

    Grab the panel (which is actually an iframe) source. The URL is of format:

    /userdefined/areas.aspx?appid=...........&formid=.......&inlineEdit=1&navItemName=Documents&oId=.....&oType=.....&pagemode=iframe&rof=true&security=......&tabSet=areaSPDocuments&theme=Outlook15White
    
  4. Replace the dotted values in the source URL with appropriate values and make the URL fully qualified prefixing with the root.

Just ensure not using any hardcoded GUIDs or IDs in the values. In this way this can be reused easily wherever needed.