Integration with Windows SharePoint Services


SharePoint Products and Technologies is a server-based collaboration infrastructure designed to organize and deliver information across your organization. In just the last year, we've seen companies of all sizes rapidly adopt SharePoint Products and Technologies as their tool of choice for company intranets, department Web sites, and team-based collaboration projects. If you've never used it before, you should set up a demo site to see how quickly and easily you can create and manage Web sites. Because more and more companies are using SharePoint Products and Technologies, they of course want to know if they can integrate their Microsoft CRM data with their SharePoint sites. By now, you already know what our answer will be. Of course you can! This section will give you two detailed examples on how to use Windows SharePoint Services to create a customer service dashboard and how to access SharePoint document libraries from the Microsoft CRM user interface.

SharePoint Products and Technologies consists of SharePoint Portal Server 2003 and Windows SharePoint Services 2003. Both offer great functionality, but because Windows SharePoint Services 2003 comes free with Microsoft Windows Server 2003, we'll use that technology for our integration examples.

Note 

If you are using SharePoint Portal Server 2003, the examples and their concepts still apply, but the steps you follow will vary slightly.

We will cover the following topics related to integrating with Windows SharePoint Services:

  • Creating a dashboard of Microsoft CRM data

  • Simple document library integration

  • Additional references

Creating a Dashboard of Microsoft CRM Data

Users love dashboards. Managers love dashboards. Executives love dashboards. Dashboards are great and everybody loves them, but in the past, creating nice, graphically pleasing Web-based dashboards required quite a bit of fancy programming and, potentially, the use of third-party charting components. Fortunately, Microsoft CRM and Windows SharePoint Services combine to make it incredibly easy for any administrator (even non-developers) to create amazing dashboards in literally minutes. This section will show you how easily you can display Microsoft CRM data in a dashboard by using the free Microsoft Office Web Parts and Components. Office Web Parts and Components is a collection of controls that allow you to publish database-driven spreadsheets and charts directly to a SharePoint site.

Note 

Explaining how to install and create SharePoint sites is beyond the scope of this book, so we'll assume that you already have a simple SharePoint site up and running. For more information, please visit: http://www.microsoft.com/windowsserver2003/technologies/sharepoint/default.mspx.

In addition to creating a dashboard page in Windows SharePoint Services, we can leverage the Microsoft CRM site map feature to display the same dashboard in the Microsoft CRM user interface. The final output of this sample is shown in Figure 11-6.

image from book
Figure 11-6: Dashboard in Microsoft CRM

To complete this sample, we will follow these steps:

  1. Download and install the Office Web Parts and Components to our SharePoint site.

  2. In Windows SharePoint Services, create a new document library, and then add a Web Part Page to it.

  3. On that page, add and configure three Web Parts to create our dashboard:

    1. A PivotChart showing the number of active cases, grouped by priority

    2. A datasheet listing the cases that have been open for longer than 15 days

    3. A hidden Web Part that helps us format the page

  4. Update the site map in Microsoft CRM with a link pointing to our SharePoint site.

Prerequisites
  1. For the server, you need Microsoft CRM 3.0 and Windows SharePoint Services 2003.

  2. On the client computer, you need Microsoft Office 2003. Earlier versions of Office will not display these Web Parts.

  3. On the client computer, you must have Microsoft Internet Explorer 6 Service Pack 1 (SP1) or later and the Microsoft Office 2003 Web Components add-in installed. Visit the following for more information: http://www.microsoft.com/downloads/details.aspx?familyid=&displaylang=en

  4. You must install the Office Web Parts and Components Web Part on the Windows SharePoint Services server.

Office Web Parts and Components doesn't install with Windows SharePoint Services by default, so follow these steps to acquire the software:

Setting Up Office Web Parts and Components
  1. Download Microsoft Office Web Parts and Components from http://www.sharepointcus-tomization.com/resources/webparts.htm, and save it to a directory on your server running Windows SharePoint Services.

  2. Log on to your server running Windows SharePoint Services and go to the directory where you saved the Microsoft Office Web Parts and Components executable file. Double-click the downloaded executable, STSTPKPL.EXE.

  3. Click Run at the next prompt, and then select the check box to accept the terms. Click Next.

  4. Click Install.

After you have satisfied the prerequisites, you're ready to create your dashboard. The steps include:

  1. Create a new document library.

  2. Create a Web Part Page (the dashboard page).

  3. Add a PivotChart Web Part.

  4. Format the PivotChart.

  5. Format the Web Part.

  6. Add an Office Datasheet Web Part.

  7. Add a Content Editor Web Part.

  8. Add the dashboard to the Microsoft CRM interface.

When we build our Web Part dashboard page, we must decide where to add it within Windows SharePoint Services. You could simply create your dashboard page in the default Shared Documents document library. However, because we want to display the dashboard in Microsoft CRM, we don't want the Windows SharePoint Services navigation toolbar or header to contain the page title. We'll show you a technique to hide the toolbar and header that comes with all pages in Windows SharePoint Services. Consequently, if a user browsed to dashboard our page directly from Windows SharePoint Services (instead of through the Microsoft CRM user interface), he or she could not access the Windows SharePoint Services toolbar and header. To help mitigate this confusion, we will create a special document library to store the pages that we plan to integrate into the Microsoft CRM interface, separate from other document libraries. Of course, there's no technical requirement to hide the toolbar and header from our dashboard page, but we think this is an important step to keep the user interface as consistent as possible.

Caution 

Perform any changes on a development or test environment first!

Let's get started by creating our new document library.

Creating a New Document Library
  1. In Microsoft Internet Explorer, browse to your SharePoint site.

  2. On the main toolbar, click Document and Lists.

  3. On the Document and Lists toolbar click Create. Then click Document Library from the Create Page Web page.

    image from book

  4. On the New Document Library page, type CRM Integration in the Name box. Select No for the questions in the Navigation and Document Versions sections. In the Document Template section, select Web Part Page. Click Create.

    image from book

You now have a document library that will contain Web pages. The next step is to create a new Web Part Page that will be our dashboard page.

Creating a Web Part Page
  1. On the CRM Integration document library page, click New Document on the document library toolbar.

  2. On the New Web Part Page page, type CRM Dashboard in the Name box, and then select Full Page, Vertical in the Layout section.

    image from book

  3. Click Create.

Now that you have the basic dashboard page (shown in Figure 11-7) in place, we will add the Web Parts to our dashboard.

image from book
Figure 11-7: Web Part Page

To populate this page with data, we will add two Office Web Parts. The first will be a PivotChart that displays the number of active cases organized by priority. The second will be a spreadsheet that shows a list of cases that have been open (unresolved) for more than 15 days. Let's begin with the PivotChart Web Part.

Adding a PivotChart Web Part
  1. On the Web Part Page, click Virtual Server Gallery in the tool pane.

  2. Drag Office PivotChart from the Web Part List section into the body of the Web Part Page.

  3. In the Web Part, click Connect to an external data source.

    image from book

  4. In the Select Data Source dialog page, create a new SQL Server connection to the Microsoft CRM database:

    1. Click +New SQL Server Connection.doc, and then click Open.

    2. In the Server Name box, enter the name of your Microsoft CRM SQL Server computer, and then select Use Windows Authentication for Log on Credentials. Click Next.

    3. In the Select the database that contains the data you want list, choose your Microsoft CRM database in the form <organization name>_mscrm.

    4. Clear the Connect to a specific table check box, click Next, and then click Finish.

  5. When you have a connection to the Microsoft CRM database, a dialog box shows all of the available tables and views. We're going to connect to one of the Microsoft CRM filtered views, called FilteredIncident. Select FilteredIncident, and then click OK.

  6. You might see the following two warnings. Click OK for both.

    image from book

    Note 

    These two warnings will continue to appear every time you or any users try to access this page until you adjust your Internet Explorer security settings. To permanently eliminate these warnings, add your SharePoint site to the list of trusted sites in Internet Explorer.

  7. Your page should look similar to the following graphic.

    image from book

  8. To start adding data fields, drag the statecodename field from the Chart Field List to the top of the chart, where it says Drop Filter Fields Here.

    Tip 

    If the field list disappears, you can always bring it back into focus by clicking the Show Field List on the PivotChart toolbar or by clicking the chart.

  9. Drag the prioritycodename field to the bottom of the chart in the Drop Category Fields Here area. Drag the prioritycodename field again, but place it on top of the chart this time, to provide a total count.

    image from book

Believe it or not, you now have a working PivotChart that pulls dynamic data from Microsoft CRM. From here, we will clean up the chart's format.

Note 

We are using the basic PivotChart functionality contained within Excel. See the Excel Help documentation for additional information regarding the use of PivotCharts.

Formatting the PivotChart
  1. First change the chart type. On the PivotChart toolbar, click Toolbar to see the available tools for your chart. Click the chart, and then click the Chart Type button on the toolbar.

    image from book

  2. In the Commands and Options dialog box, click the Type tab, and then click Bar in the list on the left. Select Clustered Bar as the chart type, and then click Save on the Pivot-Chart toolbar.

    image from book

  3. In the Commands and Options dialog box, click the Border/Fill tab, and in the Fill section, select Gradient in the Fill Type list. Move the Amount slider to the far right for a nice, light gray gradient.

    image from book

  4. To display only active cases, update the statecodename filter by clicking the down arrow next to statecodename and leaving only Active selected. Click Save.

Tip 

Remember to save your work often!

We now have our PivotChart working as we want. Our final step is to clean up the format of the Web Part.

Formatting the Web Part
  1. To open the Web Part Properties pane, click Modify Shared Page, point to Modify Shared Web Parts, and then click Office Pivot Chart.

    image from book

  2. In the Office PivotChart pane in the Appearance section, change the title to Active Cases By Priority.

  3. In the Height section, click Yes, enter 150 in the text box, and then select Pixels.

  4. Scroll down to the PivotView section, and then clear the Show Toolstrip check box to hide the Web Part toolbar.

  5. Right-click the chart, and then clear the Toolbar checkmark to turn off the PivotChart toolbar.

  6. Right-click the chart, and then clear the Drop Areas check box to hide the drop areas outlines from the user.

  7. Click OK in the Web Part Properties pane. An Internet Explorer dialog box might ask if you want to save your changes. Click OK.

    image from book

Congratulations, you have finished your Web page! Your page should look similar to the one shown in Figure 11-8; of course, the chart will display Case data from your Microsoft CRM system.

image from book
Figure 11-8: Windows SharePoint Services page after adding the Office PivotChart Web Part

Now that we've completed the PivotChart on our dashboard, our next task is to add a datasheet Web Part that lists all active cases with a created date of 15 days or older.

Adding an Office Datasheet Web Part
  1. Click Modify Shared Page, point to Add Web Parts, and then click Browse. The Add Web Parts pane appears, and the page appears in design mode.

  2. In the Browse section, click Virtual Server Gallery, and then drag Office Datasheet onto the body of the Web Part Page above the PivotChart.

  3. Click Connect to an external data source in the Web Part, and then select the data source that you used for the PivotChart. In the Select Table dialog box, select the FilteredIncident view again. Click OK, and then click Save.

  4. All of the records and columns from the Microsoft CRM Incident table appear. However, we want to update the default query to return only the records that are older than 15 days and still active. Click the down arrow on the Office Datasheet Web Part, and then click Modify Shared Web Part.

    image from book

  5. To alter the properties of the Web Part, in the Appearance section, type Cases - 15+Days Overdue in the Title box. In the Height section, click Yes, enter 150 in the text box, and select Pixels.

  6. In the PivotView section, change the connection type to SQL Command Text. Then click in the Query Text box to enable the ellipsis () button.

    image from book

  7. Click the ellipsis button to launch the Text Entry dialog box. Remove the existing query, and then add the following code.

     select  customeridname as [Customer],  subjectidname as [Subject],  casetypecodename as [Case Type],  owneridname as [Owner],  productidname as [Product],  createdon as [Created] from  filteredincident where  statecode = 0  and createdon < dateadd(d,-15,getdate()) 

  8. Click Apply. Your table of data will probably disappear. If so, you will have to add back the columns that you want to display.

  9. Click Show Field List in the Web Part toolbar and drag the following columns onto the Web Part in order: Created, Subject, Customer, Product, Case Type, and Owner. Click Save.

  10. To format the datasheet and remove the toolbar, click Toolbar on the Web Part toolbar. Click the Commands and Options button on the toolbar, and then change the font to Tahoma 8 to update the font of the column headings. Click Save.

  11. Right-click the Created column, and then click Commands and Options. Select Tahoma and 8 for the font. Repeat for each column. Click Save.

  12. Click Toolbar again in the Web Part toolbar to remove the toolbar. Click Save. Then clear Show Tool strip in the PivotView section of the properties pane. Click OK.

Your page should now resemble Figure 11-9.

image from book
Figure 11-9: Windows SharePoint Services page after adding the Office Datasheet Web Part

The last step we will perform is optional, but we feel it's worth knowing. If we were to add this page to Microsoft CRM as it is currently constructed, it would look similar to Figure 11-10. Notice that it includes the Windows SharePoint Services navigation and title bar.

image from book
Figure 11-10: Microsoft CRM dashboard page with Windows SharePoint Services navigation

Because users will access this dashboard from the Microsoft CRM interface, the Windows SharePoint Services navigation and title bar might cause confusion. We'll show you how to hide it or remove it from the dashboard page. One method to accomplish this would be to open the Web page in Microsoft Office FrontPage 2003 and change the page layout directly. We will discuss editing with FrontPage in the next example. A second method (our recommendation) is to simply hide the toolbar and header using the technique we describe next.

Windows SharePoint Services doesn't provide a user interface option for turning off the header or top navigation menu. However, because SharePoint sites use cascading style sheets styles, we can take advantage of cascading style sheets and simply hide these items. To modify the cascading style sheets, we will use a Content Editor Web Part. This Web Part allows us to add custom content and code that Windows SharePoint Services will render on the page.

Adding a Content Editor Web Part
  1. From your dashboard page in Internet Explorer, click Modify Shared Page, point to Add Web Parts, and then click Browse.

  2. In the Team Web Site Gallery section, drag the Content Editor Web Part from the Web Part List and place it above the Cases - 15 Days Overdue Web Part.

  3. Click the open the tool pane link in this Web Part, and then click Source Editor.

  4. In the Text Entry dialog box, enter the following code, and then click Save.

     <style> .ms-bannerframe { display:none; } .ms-titleareaframe { display:none; } </style> 

  5. To add just the cascading style sheets styles to the page, and not the Web Part itself, expand the Layout section and clear the Visible on Page check box. Click OK. The following graphic shows the dashboard with the top navigation and header hidden.

    image from book

Tip 

After you hide the header, you will no longer see the Modify Shared Page menu that you have been using to edit the page. To open the page in edit mode and display the hidden Content Editor Web Part, click the down arrow on the Web Part itself, and then click Modify Shared Web Part.

Our dashboard is now ready to be integrated into Microsoft CRM. We will add a link to the dashboard from the Workplace area in the application navigation pane. As you remember from Chapter 6, "Relationships and Custom Entities," you do this by editing the site map.

Adding the Dashboard to the Microsoft CRM Interface
  1. Export the site map and create a backup copy, in case you need to roll back.

  2. Open the site map in your favorite XML editor, look under the <Group Resource DescriptionResource> node, and add the following new <SubArea> code. Be sure to change <yoursharepointserver> to your Windows SharePoint Services server.

     <SubArea  Title="Dashboard" Icon="/_imgs/ico_18_miscReports.gif" Url="http://<yoursharepointserver>/CRM%20Integration/CRM%20Dashboard.aspx" /> 

  3. Add a Title attribute in the workplace Area node to get our custom subarea to display. We will add a title called Workplace.

     <Area  Resource ShowGroups="true" Icon="/_imgs/workplace_24x24.gif" DescriptionResourceId= "Workplace_Description" Title="My Work"> 

  4. Save the file, and then import your new site map into Microsoft CRM by using the Import Customizations feature.

After you update the site map, refresh your Microsoft CRM window (if you had it open) and you should see Dashboard under the My Work group. Clicking the Dashboard link opens your new dashboard in Microsoft CRM, as shown in Figure 11-11.

image from book
Figure 11-11: Dashboard using Windows SharePoint Services in Microsoft CRM

Obviously, you can expand on this concept and add multiple Web Parts to this dashboard page or even create multiple dashboard pages for each functional role at your organization.

Important 

Just like Microsoft CRM, Windows SharePoint Services uses Integrated Windows authentication so that users don't have to explicitly log on. Therefore, the data that each user sees in the dashboard is unique to his or her Microsoft CRM user security privileges! Remember that users can add the SharePoint site to their list of trusted sites in Internet Explorer to permanently eliminate the security prompts and warnings.

Simple Document Library Integration

One of the great features of Windows SharePoint Services is the document libraries that let your organization's employees share and collaborate on documents in a centralized location. Windows SharePoint Services also offers additional document management functionality, such as check in and check out, e-mail alerts, discussions, approvals, and direct integration with Microsoft Office. Many companies like using document libraries to store important documents related to their customers. You're already using Microsoft CRM to store data about customers; wouldn't it be great to link a customer's SharePoint document library to his or her Microsoft CRM Account record, so that users could access both types of information within the Microsoft CRM user interface? You can see where we're going with this, and we're going to show you how to integrate Windows SharePoint Services document libraries with the Microsoft CRM Account form.

Conceptually, we will create a single document library that stores documents for all of our accounts, and then we'll add an Account Number attribute to the document in Windows SharePoint Services to link it to a Microsoft CRM record. By linking the documents with an Account Number, our integration code will automatically filter the records from the document library to display only the documents relevant to the account currently being accessed in Microsoft CRM. To accomplish the integration of the documents and the Account record, we will require users to include an Account Number for each document that they add to the document library.

More Info 

We chose to link documents from Windows SharePoint Services to Microsoft CRM via an Account Number attribute in this example, but we could have linked them by using other methods, such as the GUID. As a reminder, Chapter 9 includes sample code to implement an auto-Account Number feature in Microsoft CRM.

The final result of our integration is shown in Figure 11-12.

image from book
Figure 11-12: Account document library using Windows SharePoint Services

This example will cover the following topics:

  • Creating a new SharePoint site

  • Creating the document library

  • Developing a redirect page

  • Configuring Microsoft CRM

  • Using the document library

  • Editing the SharePoint site with FrontPage

  • Additional enhancements

Creating a New SharePoint Site

If you're familiar with Windows SharePoint Services, you know that a single installation includes one site by default but it can support many different sites. For our document integration, we will want to have more design control over the pages within the site, and because of this, we recommend creating a new site.

Creating a SharePoint site
  1. Use Internet Explorer to browse to your SharePoint site.

  2. Click Site Settings on the main toolbar.

  3. In the Administration section, click Manage sites and workspaces. On the Sites and Workspaces page, click Create on the toolbar.

  4. On the New SharePoint Site page, enter the following:

    1. In the Title box, enter Microsoft CRM Integration. In the Description box, type SharePoint site used for integration with Microsoft CRM.

    2. In the URL name box, Type crm. Your final URL should be http://<yoursharepointserver>/crm.

    3. For User Permissions options, select Use same permissions as parent site.

    4. Click Create.

  5. On the Template Selection page, select Blank Site, and then click OK.

    Your page should resemble the page shown in Figure 11-13.

image from book
Figure 11-13: New SharePoint site

Creating the Document Library

Now that your new site is in place, we will add a document library to the site to contain all of our Account documents. We will then add a column (Account Number) to this document library. To integrate the data between Microsoft CRM and SharePoint, we will link the Microsoft CRM account number attribute and the newly created Account Number column in the document library.

After we configure our document library, we will configure a filter on the Account Number column. Then, when Windows SharePoint Services filters the page based on the account number, we will examine the URL of the filtered page and reverse engineer it to determine the URL that we need to reference within Microsoft CRM.

Creating a Document Library
  1. Click Create on the main toolbar, and then on the Create Page page, click Document Library.

  2. On the New Document Library page, enter the following:

    1. In the Title box, enter Account Documents. In the Description box, type Documents related to Microsoft CRM Account records.

    2. Select No for the question in the Navigation section.

    3. In the Document Versions section, select Yes.

    4. For Document Template, choose Microsoft Office Word document. This selection identifies Word as the default document type.

    5. Click Create.

    image from book

  3. In the Actions list, click Modify settings and columns.

  4. On the Customize Account Documents page, in the Columns section, click Add a new column.

  5. On the Add Column page, enter the following:

    1. In the Column name box, type Account Number.

    2. For The type of information in this column is, select Single line of text. This data type matches the attribute type of the Microsoft CRM field.

    3. In the Optional Settings for Column section, select Yes for the Require that this column contains information option. Leave the other default settings and click OK.

  6. On the Customize Account Documents page, click the link next to Web address to return to the document library.

    Important 

    Be sure to match the data type of your new column with the attribute of the Microsoft CRM column. Because the account number is a string (nvarchar), we will use a single line of text for our new column. Remember, if you need to find the attribute information for Microsoft CRM, you can use this link: http://<crmserver>/sdk/list.aspx.

We now want to find the URL that Windows SharePoint Services creates for a filtered view based on the Account Number. The easiest way to determine the URL is to add a test document to the document library.

Finding the URL for a Filtered View
  1. Click Upload Document on the document library toolbar.

  2. Select any document from your computer as a test. Type 1 in the Account Number box. Click Save and Close.

    image from book

  3. In the Account Documents document library, click Filter on the document library toolbar. Drop-down lists appear above each column. Select 1 in the drop-down list above the Account Number column.

    image from book

  4. Copy the URL from the Internet Explorer address bar and save it. We will be using it shortly. It should look something like this.

     http://<yoursharepointserver>/crm/Account%20Documents/Forms/AllItems.aspx?View= %7b443D4E24%2d9229%2d48A4%2d9EF9%2dB6C9810F836F%7d&FilterField1=Account%5fx0020%5fNumb er&FilterValue1=1 

As you can see from this URL, Windows SharePoint Services uses the query string parameters to set the view of its page. We will take this URL and dynamically set the FilterValue1 parameter in our .NET redirect page. Let's see how.

Developing a Redirect Page

To display documents on the Account form, we will add a link in the Account navigation pane using the ISV.config. Microsoft CRM will automatically append the GUID of the account to the query string for all links in the navigation. As we just learned, Windows SharePoint Services filters the document library by including the account number in the query string but Microsoft CRM only includes the GUID of the account. Therefore, we must create an interim redirect page that will translate the URL into the format that we need for Windows SharePoint Services to display the correct documents. We will use an ASP.NET page for the redirect page. It will use the GUID of the account to retrieve the account number from Microsoft CRM, and then it will append that number to the query string FilterValue1 parameter of the Windows SharePoint Services URL.

The page is conceptually quite simple. Microsoft CRM will pass the entityid in the query string, and we will use that to retrieve the record's account number. We will then append that value to the URL that we discovered in the last section. However, we must remove the last 1 from the URL, because we want to determine what that value will be. The URL that you will use should look similar to this:

 http://<yoursharepointserver>/crm/Account%20Documents/Forms/AllItems.aspx?View= %7b443D4E24%2d9229%2d48A4%2d9EF9%2dB6C9810F836F%7d&FilterField1=Account%5fx0020%5fNumber&Fil terValue1= 

Finally, we perform a Web redirect to the document library.

Creating a Redirect Page
  1. Open the WebSiteConnector project that you created earlier in this chapter, or create a new C# Web Application project.

  2. Add a Web Form page called DocumentRedirect.aspx.

  3. Copy the code in Listing 11-1 to the page and build it. Note that you must replace <crmserver> with the actual name of your Microsoft CRM Web server. Also, use the URL that you discovered earlier from your SharePoint site for your url variable (step 4 of the Finding the URL of a filtered view procedure).

    Listing 11-1: DocumentRedirect.aspx

    image from book
     <%@ Page Language="C#" %> <%@ Import Namespace="WorkingWithCrm.CrmSdk" %> <script runat="server"> protected void Page_Load(object sender, EventArgs e) {   string entityId = Request.QueryString["oId"];   CrmService service = new CrmService();   service.Credentials = System.Net.CredentialCache.DefaultCredentials;   service.Url = "http://<crmserver>/mscrmservices/2006/crmservice.asmx";   ColumnSet cols = new ColumnSet();   cols.Attributes = new string [] {"accountnumber"};   try   {     // Retrieve the record, casting it as the correct entity     account oAccount = (account)service.Retrieve(EntityName.account.ToString(), new Guid(ent ityId), cols);     string acctNumber = (oAccount.accountnumber == null) ? string.Empty : oAccount.accountnu mber.ToString();     string url = "http://<yoursharepointserver>/crm/Account%20Documents/Forms/ AllItems.aspx?View=%7bCE73E44C%2d0622%2d48B2%2dBC88%2d414B5EC8277F%7d&FilterField1=Account%5 fx0020%5fNumber&FilterValue1=";     url += acctNumber;     Response.Redirect(url, true);   }   catch (System.Web.Services.Protocols.SoapException ex)   {     // Handle error   } } </script> 
    image from book

  4. Since this page will be deployed on the Microsoft CRM Web server, we will reuse our standard workingwithcrm virtual web that we created earlier for deployment. Copy the assembly to the bin folder of the workingwithcrm folder on your Microsoft CRM Web server. Copy the DocumentRedirect.aspx page to the root of the WebSiteConnector virtual directory.

The code for DocumentRedirect.aspx is shown in Listing 11-1.

Configuring Microsoft CRM

After we deploy our redirect file, we just have to add a link to it from the Microsoft CRM interface. Because we want this link to display on the Account entity's navigation pane, we must update the ISV.config file.

Update the ISV.config file with the following code.

 <Entity name="account">  <!-- The Account Left Nav Bar -->  <NavBar>  <NavBarItem Icon="/_imgs/ico_18_queue.gif" Title="Documents" Url="/websiteconnector/ documentredirect.aspx"  />  </NavBar> </Entity> 

Replace the Url attribute with the appropriate path to your custom page.

Note 

Remember to make sure that Microsoft CRM enables ISV integration by checking the ISVIntegration setting in the Web.config file. The user accessing the account record must also belong to a role with the ISV Extensions privilege enabled. Review Chapter 3, "Managing Security and Information Access," for more information regarding setting up security and Chapter 10, "Client-Side SDK," for information regarding the ISV.config file.

Next, open Microsoft CRM and browse to an Account record. You should see the new Documents link in the Details section of the navigation pane. Type 1 in the Account Number box, and then click Save. Click the Documents link to see the document library, as shown in Figure 11-14.

image from book
Figure 11-14: Account Documents page in Microsoft CRM

And, because this Account's account number is now 1, you will see that the document library is correctly returning our original test document.

Using the Document Library

To ensure that our system integration is working, try out a couple of documents. From your current account, upload another document with an account number of 2, and you will see that the document will not appear in the list, but will appear with an account whose account number is 2.

Here are few additional items of interest regarding Microsoft CRM and Windows SharePoint Services:

  • Remember that Microsoft CRM caches the Web pages linked from the left navigation pane. If you need to refresh, either right-click the Windows SharePoint Services page and then click Refresh, or close and re-open the Account record.

  • When you click New Document in the document library, a Word document appears that is linked to Windows SharePoint Services. Remember selecting Word as your default document when you created the document library? That setting is what drives this functionality. Even better, when you save your document, you will be prompted for an account number, and your document will be automatically saved in your document library. Pretty cool!

  • When you click the document, Windows SharePoint Services gives you a menu of options that allows you to edit the document properties, check the document in and out, review version history, and set up e-mail alerts. You get all of this functionality from Windows SharePoint Services without writing any custom code.

  • Unfortunately, this example has the same user interface problem as our dashboard. As we currently have it constructed, users could browse to the SharePoint site from within Microsoft CRM. We will show you how that can be improved in the next section.

Editing the SharePoint Site with FrontPage

Performing a simple integration between Microsoft CRM and a Windows SharePoint Services document library requires very little code and can be accomplished in a matter of hours, not weeks. However, although this implementation is serviceable, we can make a few more quick improvements that will enhance the user interface even further.

In our dashboard example, we showed you how to add some simple style code in a Content Editor Web Part to remove the site toolbar and page header. This approach worked well for that instance, because we were working with a single Web Part Page.

In this example, we have a document library, not a Web Part Page, so we must consider the layout of additional pages (such as a document upload page, properties pages, and so on). For this example, we will use FrontPage 2003 to edit the SharePoint site.

Important 

Many professional developers use Visual Studio exclusively. However, FrontPage and Windows SharePoint Services are very tightly integrated, making adjustments simple. Therefore, we strongly recommend that you use FrontPage for this type of modification.

Changing the Page Layout with FrontPage 2003
  1. Open FrontPage 2003.

  2. On the File menu, click Open Site. In the Open Site dialog box, type http://<yoursharepointserver>/crm in the Site name box.

  3. In the Folder List, click Account Documents, and then click Forms. You will see several .aspx pages and a Word template.

    image from book

  4. Double-click AllItems.aspx to open the main document library page for editing. From here, you can use the design or code view to make changes to this page.

    Warning 

    You will be changing the Windows SharePoint Services files directly on the server! Use caution when editing any of these files, as you could break functionality. Always test your changes on a development server first.

  5. Remove the navigation and title elements; the Microsoft CRM interface will provide those for us. Note that some elements might be required for the page to render (such as the SharePoint:ListProperty element). Test the page in your browser or in the FrontPage Preview mode after each change. When you are finished removing these elements, your page should resemble the following graphic:

    image from book

  6. To change the background color, click Theme on the Format menu.

    image from book

  7. At the bottom of the Theme pane, click Create new theme to open the Customize Theme dialog box.

    image from book

  8. Click the Colors button, and then click the Custom tab. For the Background item, click the Color drop-down list, and then click More Colors.

    image from book

  9. Enter the following hex value: Hex={EE,F0,F6}. This corresponds to the light blue color of an entity's form tab. Click OK twice.

    Note 

    The actual background color in CRM is a darker blue (#ACC0E9), but the document library Web Part didn't show as well on it, so we chose the lighter color for this example. The SDK comes with a handy UI Style Guide, which is a PDF document that details all of the colors and user interface specifications for the whole application. It is an excellent reference if you are creating custom pages!

  10. Click Save As, and then enter Microsoft CRM in the Enter new theme title box. Click OK to close the Save Theme dialog box, and click OK again to close the Customize Theme dialog box.

  11. In the Theme pane, Microsoft CRM appears as an available theme. If you click the icon, you can choose to apply the theme to the selected pages or the entire site (apply as default theme). For this example, click Apply as default theme on the menu. Click Yes in the warning message.

  12. Save your page.

So what did this accomplish? Well, go back to your Account record in Microsoft CRM and look at the Documents link. Figure 11-15 shows the results.

image from book
Figure 11-15: Updated Account Documents page in Microsoft CRM

Obviously, the Web Part style is a bit different, but the cleaner user interface already makes the page appear more integrated. In addition, by removing the navigation, you prevent users from accidentally browsing to areas of Windows SharePoint Services.

You should repeat the preceding steps for the other files to clean up their look. You will be able alter the upload document (Upload.aspx), view document (DispForm.aspx), and update document (EditForm.aspx) properties pages.

You can also edit the default Word document that appears when users add new documents to your document library. Typical customizations to this might include adding your company header and logo and changing the styles of the document to match your corporate policies.

image from book
FrontPage and Ghosting

As we create new sites and begin to modify the Windows SharePoint Services files in FrontPage, we want to take a moment to mention the concept of ghosting. When we created our new Microsoft CRM site, Windows SharePoint Services did not copy all of the pages and files to a server directory or database. Instead, it created a link to the core files in a database along with the definition of the site. That process is referred to as ghosting. Ghosting improves the site's overall performance and saves disk space.

However, ghosting requires that all pages in the site use the same definition. Editing a page in FrontPage removes the link for that page and all dependent pages, instead of creating a link to the core site pages in the database. You lose the performance gains of ghosting as a result, because Windows SharePoint Services has to make a database call to retrieve the page. In addition, global changes to the site might not always apply, because the edited pages are now stored separately.

For small sites or a limited number of users, this effect might be negligible, but you should understand the impact as you begin to alter your site's pages with FrontPage.

image from book

Additional Enhancements

Obviously, forcing the user to provide the link between the document records in Windows SharePoint Services and Microsoft CRM, and with a text variable at that, is not ideal. We concede that the document integration is simplistic in its implementation. The main point of the example is that with minimal code and effort, you can use the power of Windows SharePoint Services in conjunction with Microsoft CRM to provide a quick and serviceable solution for your business.

For a more robust solution, you might prefer to use your own document Web Part, which would allow you to control the menu links, toolbar actions, styles, and so on. You might also decide to provide the integration with the document automatically, using the account's GUID instead of a user-entered number. Clearly, you can develop more elegant and robust solutions, but those solutions are probably more appropriate for Windows SharePoint Services SDK discussions.

Additional References

The following are some additional SharePoint Products and Technologies references that you might find useful:

  • http://www.microsoft.com/sharepoint

  • http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_2003_ta/html/sharepoint.asp

  • http://www.microsoft.com/resources/documentation/wss/2/all/adminguide/en-us/stsh01.mspx




Working with Microsoft Dynamics CRM 3.0
Working with Microsoft Dynamics(TM) CRM 3.0
ISBN: 0735622590
EAN: 2147483647
Year: 2006
Pages: 120

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net