Using External Data in Libraries

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.

  1. Open SharePoint Designer.
  2. 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.
  3. Select External Content Types from the left navigation
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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
  9. Save and Close the definition of the External Content Type.
  10. Go to Central Administration.
  11. Open the Business Data Connectivity Service configuration page by selecting Manage Service Application from the Application Management group and clicking Business Data Connectivity Service.
  12. 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.
  13. Exit Central Administrator
  14. Close Share Designer

Next you will create the Document Library

  1. Create a standard document library with a name of your choice.
  2. Go to Library Settings which can be found in the Settings group of the Library ribbon.
  3. 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.
  4. Select any additional fields you want to appear in the list from the External Content Type.
  5. 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

  1. 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.
  2. Enter the document name (and path) in the Upload Document dialog or use the Browse button to locate the document.
  3. 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.
  4. Click Save in the properties dialog.
  5. 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.

  1. Open the library used in the last section and go to Library Settings in the Settings group of the Library ribbon.
  2. In the General Settings section, select Advanced Settings.
  3. On the Advanced Settings page, select Edit Template in the Document Template area.  This action opens a blank Microsoft Word template.
  4. 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.
  5. 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.
  6. Next add any of the additional external fields to the template.
  7. Save and close the template
  8. Return to the list view of the library and select New Document from the New group of the Documents ribbon.
  9. 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.
  10. 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.
  11. 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.