The list our workflow will use is a document library called Status Reports. It was created through the browser using the built-in Document Library list template. We then created a new choice column (marked as required) on the library called Overall Status and gave it the values mentioned in the last section. Versioning and content approval were not enabled, and a simple information management policy was created that moves status reports to the recycle bin once they become three months old (which isn‘t really relevant to our workflow but is included as a reminder to consider growth and retention when designing your lists).
Workflow
Now we‘ll delve into the process of creating our workflow. First, we open SharePoint Designer and click the Lists and Libraries link in the navigation pane. On the Lists and Libraries page, we click the Status Reports link to navigate to the summary page for our library. We then locate the Workflows category in the lower-right portion of the screen and click the New button as shown in Figure 8-10.
Figure 8-10. Creating a new workflow on the Status Reports library
Next we‘ll see the Create List Workflow dialog and fill in the name and description of our workflow, as shown in Figure 8-11.
When we click OK on the dialog, we‘ll be taken straight to the workflow designer. All we‘ll see initially is an empty step called ―Step 1.‖ In this case, our workflow is short and doesn‘t need to be broken into multiple steps, so one step is fine. However, we‘ll rename Step 1 to ―Notify if Report is At Risk‖ (by clicking the words
―Step 1‖ in the step header and changing the value in the text box). Even with a single step, it‘s good to be descriptive.
Next, we‘ll click the Condition button in the Insert group of the ribbon and select If current item field equals value. Then we‘ll click the hyperlinks in the condition and set the values as shown in Figure 8-12.
Figure 8-12. Snapshot of workflow after configuring condition
Once the condition is in place, we‘ll add an action within it (so that the action is executed only when the condition is true). To do so, we click inside the condition where the Start typing… message is and insert the Lookup Manager of a User action (it‘s in the Relational Actions category of the menu under the Actions button in the ribbon). The action, once inserted into the workflow, displays a hyperlink for the words this user. We click the hyperlink and see the Select Users dialog. We select Workflow Lookup for a user… and click the Add button, as shown in Figure 8-13.
Clicking Add brings up the Lookup for Person or Group dialog. For Data source, we select Workflow Context. For Field from source, we select Current User. For Return field as, we select Login Name. We click OK to close the dialog and click OK again on the Select Users dialog to close that one, too.
Next we‘ll insert the Send an Email action from the Actions button in the ribbon. When this action is inserted, it appears in the designer as Email these users, where these users is a hyperlink. What we want to do next is replace these users with the e-mail address of the department manager. In our case we know that all employees who use this site are members of the same department and report to the same manager. We also know that their managers are correctly mapped in Active Directory and that Active Directory is synchronized with Office 365 using the Directory Synchronization tool ( http://bit.ly/xKJCw7). Therefore, there‘s an easy way we can get the e-mail address of the department manager, as we‘ll see in a moment.
To start configuring the e-mail action, we click the ―these users‖ hyperlink and an e-mail message dialog appears with To, CC, Subject, and body fields. We click the book icon to the right of the To field, revealing the Select Users dialog again. We again select Workflow Lookup for a User… and click Add just like before. This time, however, we choose Workflow Variables and Parameters as the data source and select Variable: manager as the field from source. (Recall that our Find Manager action stored its result in a variable called manager, as seen at the top of Figure 8-13.) For the return type of the field, this time we choose Email Address and then click OK to close the dialog (and OK again to close the Select Users dialog).
We type a simple message into the e-mail body for now, as shown in Figure 8-14. To create the link to view the report, we used the hyperlink button in the toolbar (rightmost button) above the message body and selected Current Item URL from the Workflow Context data source.
Finally, we enter ―At risk status report‖ in the subject field and click OK to save the message. The final workflow is pictured in Figure 8-15.
Figure 8-15. Final workflow in workflow designer
We‘re not quite done, though. We still need to tell SharePoint to start our workflow automatically whenever a status report is submitted. To do so, we click the Workflow Settings button in the ribbon. On the settings page, under Start Options, we uncheck the Allow this workflow to be started manually option and select Start workflow when an item is created. Now, whenever a status report is uploaded to the Status Reports list, our workflow will automatically run on that report.