This is the third installment in a four-part series about the time-off request solution, an end-to-end Microsoft Office SharePoint Server 2007 solution that uses Microsoft Office Word 2007 as a form application. In the previous post I built an Office Word 2007 document template using content controls and associated it with the Time-Off Request site content type. This post focuses on the document information panel and its ability to drive business logic in the form without any custom code.

The document information panel is a Microsoft Office InfoPath 2007 form template that is associated with a content type. This solution already uses a default document information panel, which you saw when opening the time-off request document template. The default document information panel displays all of the site columns in the Time-Off Request site content type. To create a new document information panel for this site content type:

  1. Navigate to the Site Settings page for the site collection (in this case, the Human Resources site collection).
  2. In the Galleries section, click Site content types.
  3. In the Custom Content Types section, click Time-Off Request.
  4. On the Site Content Type page, click Document Information Panel settings.
  5. On the Document Information Panel Settings page, click Create a new custom template.
  6. On the Document Information Panel Settings page, select the Always show Document Information Panel on document open and initial save for this content type check box.
  7. Click Create a new custom template.
  8. In the InfoPath Data Source Wizard, click Finish.

When the InfoPath designer starts, note that all of the site columns appear as fields in the form view. However, for this solution, the employee needs to edit only five fields, while the employee’s manager needs to edit only three fields. So, we can add a layout table (Insert | Layout Table) to the form view that displays only the editable fields. Nodes can be dragged from the Data Source task pane into the form view, which will result in the creation of controls that are bound to those nodes.

InfoPath Layout Table

One benefit to using a document information panel is the ability to connect to a secondary data source without code and then populate form fields with data received from that connection. This solution includes a custom SharePoint list within the Human Resources site collection that identifies time-off balances. Each list item has columns for the Employee, Manager, and—although not displayed in the list view—the Employee Email and Manager Email.

Time-Off Balance List

For this solution, you will change the Employee Name text box control in the document information panel to a drop-down list box control. Then, you will update the drop-down list box properties to look up values from the Time-Off Balances custom list. To make these changes, perform the following:

  1. Right-click the Employee Name text box control and click Change To | Drop-Down List Box.
  2. Double-click the Employee Name drop-down list box control.
  3. In the Drop-Down List Box Properties dialog box, click Look up values from an external data source.
  4. Click the Add button.
  5. In the first page of the Data Connection Wizard, ensure Receive data is selected and click Next.
  6. In the next page of the Data Connection Wizard, click SharePoint library or list and click Next.
  7. In the next page of the Data Connection Wizard, type the URL for the Time-Off Balances custom list and click Next.
  8. In the next page of the Data Connection Wizard, ensure Time-Off Balances is selected and click Next.
  9. In the next page of the Data Connection Wizard, ensure the Employee, Employee_Email, Manager, and Manager_Email check boxes are selected and click Next.
  10. In the next page of the Data Connection Wizard, click Next to not store a copy of the data for offline use.
  11. In the last page of the Data Connection Wizard, click Finish.
  12. In the Drop-Down List Box Properties dialog box, click the Select XPath button, located to the right of the Entries box.
  13. In the Select a Field or Group dialog box, expand dataFields, click Time-Off_Balances, and click OK.

With the InfoPath declarative rules engine, you can add logic to the document information panel that sets fields in the form’s data source based on the selection in a list. In this scenario, you will add a rule to the Employee Name drop-down list box control that sets the EmployeeEmail, ManagerName, and ManagerEmail nodes accordingly. To add the rule:

  1. In the Drop-Down List Box Properties dialog box, click Rules.
  2. In the Rules dialog box, click Add.
  3. In the Rule dialog box, click Add Action.
  4. In the Action dialog box, change the Action list value to Set a field’s value.
  5. Click the Select XPath button, located to the right of the Field box.
  6. In the Select a Field or Group dialog box, double-click the EmployeeEmail node.
  7. In the Action dialog box, click the Insert Formula button, located to the right of the Value box.
  8. In the Insert Formula dialog box, click Insert Field or Group.
  9. In the Select a Field or Group dialog box, change the Data source list value from Main to Time-Off Balances (Secondary).
  10. Expand dataFields and Time-Off_Balances, click the Employee_Email node, and click Filter Data.
  11. In the Filter Data dialog box, click Add.
  12. In the Specify Filter Conditions dialog box, change the first list value to Employee.
  13. Click the third list value and click Select a field or group.
  14. In the Select a Field or Group dialog box, change the Data source list value from Time-Off Balances (Secondary) to Main.
  15. Expand p:properties and documentManagement and double-click the EmployeeName node. Specifying a Filter Condition
  16. Click OK in all dialog boxes until you return to the Rule dialog box.
  17. Repeat Steps 3-16 for the ManagerName and ManagerEmail nodes.
  18. Click OK until all dialog boxes have been closed.

The InfoPath designer also allows us to add conditional formatting to the document information panel. For example, we can disable the three manager controls if the TimeOffStatus node is blank, which is the default value. This conditional formatting will prevent the employee from updating the Status, Reason (if “Rejected”), and Total Business Days fields when first filling out the time-off request. To add this conditional formatting:

  1. Double-click the Status drop-down list box control.
  2. In the Drop-Down List Box Properties dialog box, click the Display tab.
  3. Click Conditional Formatting.
  4. In the Conditional Formatting dialog box, click Add.
  5. In the Conditional Format dialog box, ensure TimeOffStatus is selected in the first list.
  6. Change the second list value to is blank and select the Disable this control check box.
    Adding Conditional Formatting
  7. Click OK until all dialog boxes have been closed.
  8. Repeat the previous seven steps for the Reason (if “Rejected”) and Total Business Days text box controls. For these two controls, in Step 6, select the Read-only check box.

You now have a document information panel that includes some relatively basic business logic. The next step is to publish the form template so that it will replace the default document information panel for the site content type. To publish the new document information panel:

  1. Click File | Publish.
  2. Use the Save As dialog box to save the form template to the local machine.
  3. In the first page of the Publishing Wizard, ensure As a Document Information Panel template for a SharePoint site content type or list content type (recommended) is selected and click Next.
  4. In the next page of the Publishing Wizard, click Publish.
  5. In the last page of the Publishing Wizard, click Close.
  6. Close Office InfoPath 2007.

Now, when you navigate to either the Time-Off Request or Time-Off Request Status document library and click New | Time-Off Request, the new document information panel will appear in the Office Word 2007 document template. When the employee starts a new time-off request document, he will not be able to modify the manager fields in the document information panel. Also, when he selects an Employee Name, the corresponding email and manager information is entered in the document.

In the final post about this solution, I will create Microsoft Office SharePoint Designer 2007 workflows that route tasks to the employee or employee’s manager as the time-off request document is updated.