Chapter 27. SharePoint

This chapter covers the installation and configuration of CRM 2016 to SharePoint integration, focusing primarily on SharePoint 2013 integration components. This chapter also briefly discusses extending this integration by using C# and the software development kit (SDK).


Caution

It is important to realize that when working with SharePoint and Dynamics CRM in an integrated environment, permissions are not transferred, and a restrictive user in CRM could accidentally stumble into the SharePoint document library for every account unless his or her permissions are paired across both SharePoint and CRM.


The “Client-to-Server Integration with SharePoint” section of this chapter explains how to install and configure the list component for CRM 2016 and SharePoint 2013, and the “Server-to-Server Integration with SharePoint” section explains how you can integrate CRM Online only with SharePoint On-Premises or Online without installing the list component. Server-to-server integration is recommended over client-to-server due to following reasons:

Image For client-to-server integration, the user needs to sign in to both Dynamics CRM and SharePoint, whereas for server-to-server integration, the user needs to sign in only to CRM.

Image The list component must be installed for client-to-server integration, and no software needs to be installed for server-to server integration.

Image The list component are a SharePoint sandboxed solution and are being deprecated and will no longer be available for both SharePoint On-Premises and Online.


Tip

With all levels of integration, if you are using Outlook, you must run in Online mode to access SharePoint features.


SharePoint and Dynamics CRM 2016

You can use the document management capabilities of SharePoint in Dynamics CRM 2016 just as in CRM 2015. CRM 2016 supports the following SharePoint editions:

Image Microsoft SharePoint 2013

Image Microsoft SharePoint 2010

Image Microsoft SharePoint Online


Note

Since Microsoft Dynamics CRM 2011, Microsoft Dynamics CRM has made native SharePoint integration options available out of the box. If however you prefer to use the list component (i.e. leverage the non-native integration), you can do so by installing and configuring the list component. Refer later in this chapter under ‘Basic Integration’ for more information about this.


The document management integration shows up in two places. First, there is a Documents view on every record in CRM, as shown in Figure 27.1. This integration option allows users to access SharePoint documents by entity across the application.

Image

FIGURE 27.1 Documents option, as shown on the related drop-down for the account record.

Second, there is the Document Management page in System > Settings (see Figure 27.2). This is where administrators set up and configure the SharePoint options that allow the SharePoint documents (refer to Figure 27.1) to be referenced and where they will ultimately reside.

Image

FIGURE 27.2 Document Management console in CRM 2016.

Options available under Document Management include the following:

Image Document Management Settings—This is where you specify which entities will use document management. You can also choose to apply autostructuring around either the account or the contact.

Image Install List Component—The entire purpose of this section is to download the latest version of the list component. At publication time, this included crmlistcomponent.wsp and a PowerShell script to set up a SharePoint site. The list component automatically creates document libraries in SharePoint. The list component includes the following features and benefits:

Image Automatic document library creation in SharePoint, applying a nested organizational structure specified in the Document Management Settings Wizard

Image Automatic site object management in CRM

Image A more secure and user-friendly IFRAME view of SharePoint from within CRM

Image SharePoint Sites—When you run the Document Management Settings Wizard, a site is created here. You can also create sites manually or modify sites that are created automatically.

Image SharePoint Document Locations—This is where you view all the document locations that have been created, create new locations, and modify existing locations.

Image Enable Server-Based SharePoint Integration—You can use this option to enable Dynamics CRM SharePoint integration without installing the list component or any other software.

Server-to-Server Integration with SharePoint

Server-to-server integration with SharePoint is supported for Microsoft Dynamics CRM Online in versions since CRM 2015 Update 1 and SharePoint On-Premises or Online. You do not need to install the Microsoft Dynamics CRM list component in SharePoint or any other software to have SharePoint document management functionality within CRM. If you have enabled server-based SharePoint integration, you can’t revert to client-based authentication.

Follow these steps to integrate SharePoint 2013 Online and Dynamics CRM 2016 Online:

1. Log on to Dynamics CRM Online as a user having the System Administrator security role and go to Settings > Document Management.

2. Click Enable Server-Based SharePoint Integration to start the wizard for Dynamics CRM Online and SharePoint integration.

3. When the wizard asks you about your SharePoint deployment type, select Online (see Figure 27.3). Click Next.

Image

FIGURE 27.3 SharePoint Deployment Options.

4. When the wizard asks you about the SharePoint site URL, enter it, making sure Dynamics CRM Online and SharePoint Online belong to same Office 365 tenant. The wizard validates the SharePoint site and displays the result there.

5. When the wizard warns you that if you enable server-side integration, you cannot enable or use client-side integration, click Enable.

6. When you see the confirmation message that server-side integration with SharePoint is complete, click the Open Document Management Settings Wizard check box and click Finish (see Figure 27.4).

Image

FIGURE 27.4 Completing the SharePoint setup.

7. In the Document Management Settings dialog, select the check box in front of appropriate entity names and provide the SharePoint site URL. Click Next. The wizard validates the SharePoint site URL.

8. When the wizard asks you how you want to maintain folder structure, select Account or Contact from the drop-down and select the Based on Entity check box (see Figure 27.5). Click Next.

Image

FIGURE 27.5 SharePoint folder options.

9. On the next page, which says that document libraries are being created at the path you specified, click OK.

10. On the next page, which shows the status for all the entities you have selected and shows a failure reason if there was an error for any entity, click Finish. The setup is complete.

If you go to any account record in Dynamics CRM and click Documents, you see a pop-up message about creating a folder in the SharePoint document library (see Figure 27.6). Click Confirm.

Image

FIGURE 27.6 Creating SharePoint folders.

Once the SharePoint document library is created, you can create new or upload existing documents, and you can also perform SharePoint functions from within the grid interface, such as Check In and Check Out.

Client-to-Server Integration with SharePoint

You have to install the list component in a sandboxed environment of SharePoint to enable SharePoint integration with Dynamics CRM.


Note

Follow the instructions for installing the list component in this section if you choose to not use the native integration in your production instance.


This integration is supported for both On-Premises and Online versions of Dynamics CRM and SharePoint. Follow these steps to enable client-to-server integration of Dynamics CRM Online with SharePoint Online:

1. Log on to Dynamics CRM as a user having the System Administrator security role and go to Settings > Document Management.

2. Click Install List Component. In the pop-up window that appears, download the list component for SharePoint 2010 or SharePoint 2013. The SharePoint 2013 extract has three files: crmlistcomponent.wsp (the list component), AllowHtcExtn.ps1 (the PowerShell script), and mscrmsharepointeula.tx (the EULA). HTML components (.htc) files are not enabled on SharePoint 2013 by default. To enable HTC, you have to run AllowHtcExtn.ps1 on the SharePoint server. This step is not required for SharePoint Online. Open PowerShell and navigate to the folder where AllowHtcExtn.ps1 file is extracted. Type the following command and then press Enter:

./AllowHtcExtn.ps1 https://sharepointserver/

3. Because SharePoint Online does not allow you to install solutions by default, log in to the Office 365 Admin Portal and click Admin > SharePoint in the left navigation pane, as shown in Figure 27.7.

Image

FIGURE 27.7 Office 365 Admin Portal.

4. In the new window that appears, click Settings on the left and then scroll down. Under Custom Script, click Allow Users to Run Custom Script on Self-service Created Sites. Click OK. The changes are made, but it may take up to 24 hours for them to be effective.

5. Log in to SharePoint and click the gear icon and then select Site Settings, as shown in Figure 27.8.

Image

FIGURE 27.8 Selecting Site Settings.

6. Click Solutions under Web Designer Galleries.

7. Click the Upload Solution button.

8. Click the Browse button and select the SharePoint 2013 list component file crmlistcomponent.wsp. Click OK. The Dynamics CRM list component is uploaded to SharePoint.

9. Click the Activate button to activate the solution and click the Close button to complete the installation.

When the solution is activated, the status appears as Activated in the Solution Gallery, as shown in Figure 27.9.

Image

FIGURE 27.9 Activated SharePoint.

10. Go to Settings > Document Management in Dynamics CRM and click Document Management Settings. In the wizard that appears, select the entities for which you want document management to be enabled and provide the URL of the SharePoint site, as shown in Figure 27.10.

Image

FIGURE 27.10 Specifying the SharePoint URL.

11. When the wizard asks you to select the Account or Contact entity for the folder structure, confirm your selection to continue.

When the document library creation process is complete, the wizard shows the status of the document library for each entity and the failure reason if there was an error.

Integration Features

Once you have installed crmlistcomponent.wsp, creation of document libraries for records is automated. Open a record of your base type or of a type that you set in the wizard to have integration features enabled. Click the Documents section, and CRM detects that a document library for this record needs to be created.

If you click OK, a folder is created for you, and the document locations load the library that was just created.

The options listed in the frame are standard SharePoint options. You can create new folders, upload documents, edit documents, check in, check out, and so on. You can also open the documents directly from CRM without having to first open SharePoint. Any records created as child records to this account (after this step) have their document libraries placed in the Webfortis folder, provided that Account is set as the base type.

If you click Cancel, you have no location created. You can open the Document Locations drop-down and click Add Location to specify where you want this document library to be, or you can link to another document library if it already exists (see Figure 27.11).

Image

FIGURE 27.11 New or existing library option.

Document Location Option

As you can see in Figure 27.11, you have two options with regard to the document location: You can specify a preexisting SharePoint folder, or you can have CRM create a new folder in a preexisting location.

If you choose to create a new folder, you can specify its name and where it will be created. It can be at the root level, or it can be a subfolder to any preexisting document library. The parent or site location lookup can be either a site or a document location.

If you open the lookup and filter based on document location, you can see all the current locations that will be available as parent folders. When you have finished, click Save, and you can choose between the two locations in the Document Locations drop-down.

You can view your document locations as they are created in Settings > Document Management > Document Locations in CRM.


Tip

Notice that your document locations have automatically generated names. However, you can rename them here.


You can view all of a document location’s child locations. Figure 27.12 shows the root Account folder. By navigating to Child Locations, you can see the folder created for Webfortis.

Image

FIGURE 27.12 Renaming a document location.

You can manage the structure of your site and the document libraries manually through the Document Management section as well: Just open a SharePoint site in Document Management, select your site, and click Edit.

Open the child locations and click Add New Document Location. Then fill in the name and relative URL.


Note

A relative URL is the document library URL relative to the parent site or location. So, if a default site has the URL https://webfortissp.sharepoint.com/, and the document library has URL https://webfortissp.sharepoint.com/customLocation, customLocation is the relative URL.



Caution

Keep in mind that you cannot use this method unless the folder already exists in SharePoint. If it does not exist, you are warned. If you create orphaned document locations, they show up as failures when you validate your site.


Record GUID in Folder Name

When folders are created automatically, the folder name has the record name and record globally unique identifier (GUID) appended to it. You can go to SharePoint and check the folder name (see Figure 27.13). This capability helps in extending integration with Dynamics CRM because the record GUID is easily available in SharePoint.

Image

FIGURE 27.13 The folder name with the record name has the record GUID appended.

You can also create document libraries for custom entities. The only requirement is that you enable the Document Management check box (see Figure 27.14).

Image

FIGURE 27.14 Document Management selected on the entity.

If you run the wizard again, your custom entity appears in the list.

Extending the Integration

The SDK enables system administrators to extend CRM–SharePoint integration. The following sections cover some of these options.

Entities

The following entities are available for configuration purposes:

Image SharePointSite—This has standard entity metadata, plus attributes that are SharePoint site specific, such as AbsoluteUrl, RelativeUrl, ParentSiteOrLocation (EntityReference), ValidationStatus, and ValidationStatusReason. These are all self-explanatory. The IsDefault property denotes whether the site is your organization’s default location.

Image SharePointDocumentLocation—This is basically the same as SharePointSite. The SharePointDocumentLocation entity makes use of RegardingObjectId to associate a location with a specific record.

Configuration Message

The message RetrieveAbsoluteAndSiteCollectionUrlRequest is available for configuration purposes. In addition to being a mouthful, this message retrieves AbsoluteUrl and SiteCollectionUrl, and it takes a document location entity reference as the Target parameter. Note that this message works only if the following are true:

Image crmlistcomponent.wsp was installed.

Image The location for the parent site exists in CRM.

Image The SharePointSite.IsGridPresent property was set to true when the parent location record was created.

You can perform all standard create/retrieve/update/delete (CRUD) operations on these new entities. For more information about the CRUD operations, see the SDK.

Operations in SharePoint

Now that you know how to handle the CRM 2016 SharePoint site structure, let’s look at the corresponding operations in SharePoint 2013. SharePoint 2013 offers many services that enable you to interact with its contents. This section looks briefly at the following services:

Image listsService—Two useful functions are GetList and AddList. GetList retrieves a list, and AddList creates a list. Listing 27.1 provides a sample function that tries to retrieve a list, and if that list does not exist, the function creates the list.


Note

To use listsService and copyService, be sure to add the following two references:

Image listsService—http://sharepoint2013/_vti_bin/Lists.asmx

Image copyService—http://sharepoint2013/_vti_bin/copy.asmx


LISTING 27.1 Retrieving or Creating a List

        static XmlNode processList(string listname, string listDescr, int libtype)

        {
            listsService.Lists listSvc = new listsService.Lists();
            listSvc.UseDefaultCredentials = true;
            XmlNode result = null;
            try
            {

                result = listSvc.GetList(listname);
            }
            catch (System.Web.Services.Protocols.SoapException soExGET)
            {
                if (soExGET.Detail["errorcode"].InnerText == "0x82000006")
                {
                    try
                    {
                        result = listSvc.AddList(listname, listDescr, libtype);
                    }
                    catch (System.Web.Services.Protocols.SoapException soExADD)
                    {

                        ErrorLog.handle(soExGET.Detail.InnerText, soExADD.Detail.
                        InnerText);
                        return null;
                    }
                }
                else
                {
                    ErrorLog.handle(soExGET.Detail.InnerText);
                    return null;
                }
            }
            return result;
        }


Tip

To create a document library, set libType to 101.


Image copyService—This service contains the CopyIntoItems function, which uploads content (as bytes) to a SharePoint library. Listing 27.2 is an example of this function in use.

LISTING 27.2 CopyIntoItems Function

        public uint uploadFile(string fileName, string[] desinationUrl, byte[]
        stream)

        {
            copyService.Copy copySvc = new copyService.Copy();
            copySvc.UseDefaultCredentials = true;
            uint result = 0;
            bool Throw = false;
            CopyResult[] results = null;
            FieldInformation descInfo = new FieldInformation()
            {
                DisplayName = "Description",
                Type = FieldType.Text,
                Value = "Automatic Upload from CRM"
            };
            FieldInformation[] inf = new FieldInformation[] { descInfo };
            try
            {
                result = copySvc.CopyIntoItems("http://crm2011", desinationUrl, inf,
                stream, out results);
                foreach (CopyResult cr in results)
                {
                    if (cr.ErrorCode != CopyErrorCode.Success)
                    {

                        ErrorLog.handle("Error After File Upload Attempt: " +
                        cr.ErrorMessage);
                        Throw = true;
                    }
                }
            }
            catch (System.Web.Services.Protocols.SoapException soExCopy)
            {
                ErrorLog.handle(soExCopy.Detail.InnerText, result.ToString());
                throw new Exception(soExCopy.Detail.InnerText);
            }
            if (Throw)
                throw new Exception("The upload file method has failed.");
            return result;
        }

So, for example, if you want a plug-in to retrieve an attachment as bytes and upload it to SharePoint, you’re about 90% of the way there. If you are operating on ActivityMimeAttachment, you can use the following to retrieve the attachment as bytes:

byte[] filecontent = new UTF8Encoding(true).GetBytes(
(string)_this.Attributes["body"]);

Just as with CRM 2016, you can write plug-ins that trigger on the creation, updating, and deletion of SharePointSite, SharePointDocument, and SharePointDocumentLocation entities.

OneNote Integration

Microsoft enabled OneNote integration with Dynamics CRM Online 2015 Update 1. To use the OneNote integration, you must have SharePoint integration with Dynamics CRM Online enabled, as OneNote documents are stored in the SharePoint document library.

Follow these steps to configure OneNote Integration with Dynamics CRM:

1. Log on to Dynamics CRM as a user having the System Administrator security role and go to Settings > Document Management. Click OneNote Integration.

2. When the wizard shows entities that have document management already enabled, select the check box in front of entity name to enable OneNote integration (as shown in Figure 27.15). Alternatively, you can select Customizations > OneNote Integration for that entity. Make sure Document Management is enabled for that entity.

Image

FIGURE 27.15 Selecting entities to enable OneNote integration.

3. Open any record for the entity where OneNote integration is enabled. You can see OneNote tab in the activity wall for that record. The new notebook is created in the default section with the default title Untitled (see Figure 27.16)

Image

FIGURE 27.16 New OneNote notebook.

4. Click the Untitled link to open notebook in the OneNote app or OneNote Online in your web browser.

5. To view your OneNote records, go to the Documents section of a record, and you can see the OneNote records there.

Summary

This chapter explains how to integrate CRM 2016 with SharePoint 2013 and how to manipulate features to get the data structure you desire. It talks about how to do client-to-server and server-to-server SharePoint integration with Dynamics CRM.

The chapter also briefly covers the additions to the CRM SDK and ways to connect to SharePoint and perform basic custom integrations. It also shows steps to enable OneNote integration with Dynamics CRM.

As mentioned early in the chapter, it is important to realize that when working with SharePoint and Dynamics CRM in an integrated environment, permissions are not transferred, and a restrictive user in CRM could accidentally stumble into the SharePoint document library for every account unless his or her permissions are paired across both SharePoint and CRM.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset