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.

image

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 == "") {
   return;
}

// 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) {
   Xrm.Page.ui.tabs.get("Documents").setVisible(true);
   documentIFrame.setSrc(docViewUrl);
}
else {
   Xrm.Page.ui.tabs.get("Documents").setVisible(false);
}
Advertisements

Customizing your CRM platform the “right way”

Over the course of my consulting experiences, I have learned to work with different platforms and products “the right way.” This means that when you are using a product (for example Microsoft Dynamics CRM), you are agreeing to use the product in the ways specified by the makers of the product. It’s like when you buy a car, there are parts that go with it and if you need to change them, you need to get them from the manufacturer. When you start modifying the car with custom parts, you lose your manufacturer’s warranty. Same thing with a phone, you jailbreak it, you don’t get support anymore. The reason behind that is very simple. When you make changes that are not prescribed by the maker of a product, it’s possible that you altered the way the product works (i.e. you may have broken it or it may break in the future), therefore the manufacturer can no longer support it because it doesn’t know if it still works as designed.

When it comes to software and especially in the case of CRM, it is very important not to break that contract. There are a few things to consider if you do and they are very well documented:

  • Unsupported changes are dangerous by nature, you don’t know what the impact is on things that you are not supposed to have control over
  • They will probably break in the future (after a patch or upgrade)
  • They can bring tons of other issues (performance, testability, bugs…)

If you are buying a product that is integrated with Dynamics CRM (ISV solution), always ask this question to the vendor: “Is you product and/or integration built in a supported way by following all Microsoft customization guidelines and APIs”? See the table of what should be your reaction based on the answer below

Answer My2cents What to do
No That’s just bad. It will either stop working at some point or it will break something. Run away!
I don’t know If the vendor doesn’t know, it means he/she is not really aware of what the impact of unsupported customizations are. That sends a wrong message and represents a serious risk. Run away or hire a technology expert to validate that all is supported.
Yes Perfecto! The vendor knows what it means and understand the importance of supported customizations. It’s a go! To protect yourself, make sure it’s mentioned in your purchase contract.

As consultant and community contributor, I keep seeing a lot of web application and ISV providers that integrate with different CRM or other platforms by simply checking out how to do stuff online and customization the platform in unsupported ways to achieve their goal and sell their product. Keep in mind that working with a platform requires the due diligence of working with experts who know how to customize it. Taking shortcuts can seem like a great idea to quickly go to market but consequences can be bad and the result is often hiring experts to figure out what is wrong when they should have been brought in from the beginning.

It’s OK to use unsupported customization as long as you are aware of the risks and are willing to live with them.

You can read more on unsupported customization for MS Dynamics CRM on the links below.

http://dynamicsuniversity.com/blog/customizing-microsoft-dynamics-crm-2011-supported-or-not-supported
http://gustafwesterlund.blogspot.ca/2012/06/unsupported-customizations.html
http://gonzaloruizcrm.blogspot.ca/2011/08/risks-of-unsupported-customizations-in.html

Cheers