With Business Connectivity Services in SharePoint 2010, you are able to use Microsoft SharePoint 2010 Search to connect to external data, such as your Microsoft Dynamics CRM 2011 database. The Business Connectivity Services (BCS) is able to index your external CRM data using what is called an External Content Type (ECT).

Before proceeding, I recommend you going through my previous posts, Search Your Microsoft Dynamics CRM 2011 Data with Business Connectivity Services in SharePoint 2010 Search and Associating Related Entities within Microsoft Dynamics CRM 2011 Software Using Business Connectivity Services in SharePoint 2010 Search. This article will be building upon the examples discussed previously.

In my previous blog posts, I showed you how to create a Microsoft SharePoint 2010 Search web site to find all your accounts in your Microsoft Dynamics CRM 2011 database. We also covered how to associate related entities in Microsoft Dynamics CRM 2011. From searching the accounts in the database, we were able to see all associated contacts to each account.

What if your database contains thousands of accounts? Your search results can get pretty extensive. So, to make your searching a little easier, we are going to cover restrictions. This will allow you to further define your searches and narrow down the results to find specifically what you are looking for. We will configure a new search metadata and add it to your advanced search properties to allow you to filter by Account Status.

Before we begin, I again want to emphasize the importance of taking complete backups before doing anything in your environment.

Step 1: Configure New Search Metadata Managed Properties

In this step, we will create two new metadata managed properties. These will be used by the Advanced Search.

1. Start Microsoft SharePoint 2010 Central Administration.

Microsoft SharePoint 2010 Central Administration

2. Under Application Management, click Manage service applications.  

Manage Service Applications
3. Under Name, click Business Data Connectivity Service.
4. On the left side, under Queries and Results, click Metadata Properties.
5. Click New Managed Property.
6. For Property name:, type AccountEntityType.
7. Click Add Mapping, select AV_AccountsRead ListElement.EntityType(Text), and click OK. You will have to have created these views in your database and ran a Full Crawl (covered in previous blog post, Search Your Microsoft Dynamics CRm 2011 Software with Business Connectivity Services in SharePoint 2010 Search) before being able to see this custom crawled property.

New Managed Property

8. Now do the same for Account Status. Click New Managed Property.
9. For Property name:, type AccountStatus.
10. Click Add Mapping, select AV_AccountRead ListElement.AccountStatus(Text), and click OK.
11. Click Ok.

Step 2: Create a Microsoft SharePoint 2010 Search Properties XML File

This step will get you the XML code that you will need to edit any of the property changes you make to the Microsoft SharePoint Search site. This is for the use of Advanced Search.

1. In Internet Explorer, navigate to the Advanced Search from the CRM Search site previously created.
2. On the Site Actions drop down, select Edit Page.
3. Select the Advanced Search Box Web Part in the center of the screen.
4. Under the Options tab in the ribbon, click on Web Part Properties.
5. You should see an Advanced Search Box navigation pane appear on the right. Expand the Properties tab.

Advanced Search Box

6. Click inside the Properties field and click on the button to the right of it and a Text Editor window will popup.
7. Select all the text and Copy it.
8. Click Cancel.
9. Start Notepad.
10. Paste all of the text inside of Notepad.
11. Under File, click Save As.
12. Navigate to a location you would like to save this file.
13. For File name, name it Properties.xml.
14. In the Save as type drop down, select All Files.
15. Click Save.
16. Close out of Notepad.
17. Make a copy of this file and save it somewhere safe. This will be your backup of the original xml code.

Step 3: Editing Properties XML in Microsoft SharePoint Designer

This step will show you how to edit the Properties XML for your Microsoft SharePoint Search site. In the Advanced Search, you will be able to restrict our search by the Account entity, in case you have added the capability to search for more entity types other than Account and Contact and do not wish to have them all show as results. You will also be able to restrict by Account Status in case you want to restrict your search to show only active accounts.

1. Open Microsoft SharePoint Designer.
2. Right click on the Properties.xml file you created and select Edit with Microsoft SharePoint Designer.
3. Under the Edit tab in the ribbon, click on XML to make the code more organized.
4. In the XML, search for the tag <PropertyDefs>.
5. Under <PropertyDefs>, add these two lines:
a. <PropertyDef Name=”AccountEntityType” DataType=”text” DisplayName=”Accounts Entity”/>
b. <PropertyDef Name=”AccountStatus” DataType=”text” DisplayName=”Account Status”/>
6. Still in the XML, search for the tag <ResultType DisplayName=”All Results” Name=”default”>.
7. Under <KeywordQuery/>, add these lines:
a. <PropertyRef Name=”AccountEntityType” />
b. <PropertyRef Name=”AccountStatus” />
8. You will also need to add a few lines for a new ResultType
a. <ResultType DisplayName=”Accounts” Name=”AccountEntityType”>
b. <KeywordQuery>AccountEntityType=”Accounts”</KeywordQuery>
c. <PropertyRef Name=”AccountEntityType” />
d. <PropertyRef Name=”AccountStatus” />
e. </ResultType>
9. Click Save.
10. Open the updated Properties.xml file in Notepad.
11. Select and copy all text.
12. In Internet Explorer, navigate to the Advanced Search from the CRM Search site previously created.
13. On the Site Actions drop down, select Edit Page.
14. Select the Advanced Search Box Web Part in the center of the screen.
15. Under the Options tab in the ribbon, click on Web Part Properties.
16. You should see an Advanced Search Box navigation pane appear on the right. Expand the Properties tab.
17. Click inside the Properties field and click on the button to the right of it and a Text Editor window will popup.
18. Select all the text and delete it.
19. Paste in the newly copied text.
20. Click Apply and then OK.
21. Click Stop Editing.
22. You will now want to run a Full Crawl (covered in previous blog post, Search Your Microsoft Dynamics CRM 2011 Software with Business Connectivity Services in SharePoint 2010 Search).
23. Click on Advanced on your search page to use your newly created restrictions.

You should now notice in the Advanced Search page that you can select Accounts as a Result type. You will also be able to restrict your search by the newly created Accounts Entity and Account Status. An example of restricting by Account Status is that you could set it to Equals Active and click Search. Now all of your search results will be active accounts.

Keep in mind that I have kept this example simple. There are many possibilities with what you can do with restrictions. Feel free to get creative. Also, restrictions do not have to be in the Advanced Search only. This will be covered in the next part of this series. We will discuss how to customize content search refinement in Microsoft SharePoint 2010 Search. That means you will be able to further narrow your results from the search results page.

Write A Comment