This time I will look at adding an External Content Type field to a library. One way you could use external data with a Word document might be to supply address information from an external SQL Server data table when the user selects a person. Some of the steps to accomplish this task you may have already done through previous topics, but I will include the steps here again for completeness.
- Open SharePoint Designer.
- Select the site you want to work in from the Recent Sites list or click the Open Site button to enter the address of your site.
- Select External Content Types from the left navigation
- If there is already a content type you can use, you can skip ahead to create the document library. Otherwise, click External Content Type in the New group of the External Content Types ribbon.
- Supply a Name for the content type. You can use the same name as the display name or provide a more user friendly display name.
- When working with external data in Microsoft Word, you can use the Generic List Office Item Type since we will not need to map fields to Outlook items.
- Use the link for External System to define the connection to the external data and define the operations needed. If a connection already exists to the database, you can reuse it to save resources or you can define a new connection. A SQL Connection requires the name of the server, the database, and the user authentication method.
- Next define the operations you need from: Create, Read Item, Update, Delete and Read List. If you only need to access data, you may be fine with just the Read Item and Read List operation. Be sure to define which fields to display in the picker as this will be how you will select which record to use
- Save and Close the definition of the External Content Type.
- Go to Central Administration.
- Open the Business Data Connectivity Service configuration page by selecting Manage Service Application from the Application Management group and clicking Business Data Connectivity Service.
- Add the users and/or groups that will need to use this content type by opening the Business Data Connectivity Services dropdown and selecting Set Permissions.
- Exit Central Administrator
- Close Share Designer
Next you will create the Document Library
- Create a standard document library with a name of your choice.
- Go to Library Settings which can be found in the Settings group of the Library ribbon.
- Add a new column of type External Data. Provide an appropriate name for the column. Then use the selection box to pick the External Content Type and the field from the content type that you want to display in this column. Note you do not have to select the columns that appear in the dropdown pick list for this field. This information was set when you defined the content type in SharePoint Designer.
- Select any additional fields you want to appear in the list from the External Content Type.
- Click OK to complete the column definition and return to the list by clicking the list name in the breadcrumbs at the top of the Library Settings page.
Upload Documents into the Library
- Upload documents into the library using the Upload Document option in the New group of the library’s Document ribbon. Note that you can upload either single or multiple documents. Let’s assume you upload a single document.
- Enter the document name (and path) in the Upload Document dialog or use the Browse button to locate the document.
- After clicking OK, the item properties dialog appears. You may have other fields defined for this library that you can fill in, but the important one for this discussion is the external content type field. Use the Select External Item button (to the far right of the field) to display the picker dialog. Select an item from the picker and click OK.
- Click Save in the properties dialog.
- Notice the library now shows your uploaded document along with populated values for all of the external content type fields.
Using External Data in your Word Document – The final section of this topic looks at including external data in your Word documents created from a modified default template in a SharePoint library.
- Open the library used in the last section and go to Library Settings in the Settings group of the Library ribbon.
- In the General Settings section, select Advanced Settings.
- On the Advanced Settings page, select Edit Template in the Document Template area. This action opens a blank Microsoft Word template.
- In the template you can add any text that you want to appear on every instance of a new document in this library. By creating a form on this template, you can create a Word based form library.
- To add external data to the template, position your cursor where you want the first field from your external data to appear. This field should be the field that you defined as a column in the library. When you use this template to create a new document instance, this field allows you to select from the picker list for the external data. With the cursor positioned, open Word’s Insert ribbon and expand the dropdown menu for Quick Parts. Choose the Document Property option and select the external field that you used to define the external data column.
- Next add any of the additional external fields to the template.
- Save and close the template
- Return to the list view of the library and select New Document from the New group of the Documents ribbon.
- When the template opens as a new document, you can click the first external content field to display the two option buttons to the right of the field. Click the Select External Item(s) button to display the pick list. It may take a few seconds to open.
- Select an item from the pick list and click OK. Notice that the other external data fields populate with the corresponding values of the fields in the external content type.
- Save the Word document and close Word. Returning to the library, you should now see the newly saved document along with the external data populating the newly added row.