Sam's Microsoft Dynamics 365 Blog

Tuesday, 23 October 2018

Display SharePoint Documents on Form in MS Dynamics CRM


Here’s an easy way to embed the SharePoint document window you’d normally get by navigating to “Documents” under related records, which includes all the native functionality like search, upload, 
This might fall under the area of semi/not supported but if it happens to break one day you won’t have invested too much.

You’ll need to create an iFrame for the SharePoint content, probably within it’s own tab. Remember what you name the iFrame as you’ll need to modify with that value. 

When configuring the iFrame...

On the General tab:

  • Restrict cross-frame scripting… to Unchecked
On the Formatting tab:
  • Number of Rows to 34
  • Scrolling to Never
  • Display Border to Unchecked
You could set the rows to a lower number, you’d just end up with a scrollbar despite the never scroll setting. 

Take this code and update the iFrame name and add it to the form. Call SetDocumentFrame during the form’s OnLoad event.







function SetDocumentiFrame() {

    try {
        // Get Subgrid URL
        var url = Xrm.Page.context.getClientUrl() +
            "/userdefined/areas.aspx?formid=ab44efca-df12-432e-a74a-83de61c3f3e9&inlineEdit=1&navItemName=Documents&oId=%7b" +
            Xrm.Page.data.entity.getId().replace("{", "").replace("}", "") + "%7d&oType=" +
            Xrm.Page.context.getQueryStringParameters().etc +
            "&pagemode=iframe&rof=true&security=852023&tabSet=areaSPDocuments&theme=Outlook15White";

        ///Append subgrid in Iframe
        Xrm.Page.getControl("IFRAME_SharePointDocuments").setSrc(url);
    }
    catch (err) {

    }


}


If you’re doing this, you might also consider turning on the option to auto-create SharePoint folders. Otherwise people are going to be getting prompted. You can find this under:

Settings => Document Management => Document Management Settings and then it’s on the 2nd page. 





With any luck, you’ll end up with something like this:








Web Resource vs PCF vs Canvas App - which of the one is used?

While started working on specific Business Requirements related to custom layout, there is a always common question that "where to star...