22.3. A Workflow Scenario: Newsletters

Workflow Designer allows you to create workflows that can be used to collect information from one or more users. The information collected can then be processed based on the logical requirements of the process. This scenario illustrates the use of the workflow actions provided by Workflow Designer to gather information from users.

22.3.1. Understanding the scenario

The sales department publishes weekly newsletters consisting of content targeted for the employees in the department. Each week, information is collected from subdepartments Sales A, Sales B, and Sales C and is then collated to form a single newsletter that's sent to the entire department. Each subdepartment has a point of contact who's responsible for submitting newsletter content for that subdepartment. Once the newsletter content is collected, it's reviewed by a senior manager and, on approval, subsequently sent to the employees as an e-mail.

22.3.2. Implementing the scenario by using Workflow Designer

Open the SharePoint site where you want to create the list that the workflow uses to store and collate data collected from the users. To implement the preceding scenario using Workflow Designer, follow these steps:

  1. Choose Site Actions Create to open the Create page.

  2. In the Custom Lists section, click Custom List to open the New page, type NewsLetters in the Name text field, keep the rest of the settings as default, and then click Create. The newly created NewsLetters list opens in the AllItems view.

  3. Choose Site Settings Create Column to open the Create Column page.

  4. As shown in Figure 22.22, type ContentSalesA in the Name text field and then choose Multiple lines of text as the type for this column.

    Figure 22.22. Creating columns for storing collected newsletter content
  5. Keep the other settings as default and then click Create to create the column.

  6. Using the previous steps, create two more columns — ContentSalesB and ContentSalesC — in the NewsLetters list.

  7. Open the site in SharePoint Designer and then choose File New Workflow to open Workflow Designer.

  8. As shown in Figure 22.23, type a name for the workflow, associate it with the NewsLetters list, and then specify for it to start whenever a new item is created.

  9. Click Variables to open the Workflow Local Variables dialog box. Here you create three workflow variables — SalesA, SalesB, and SalesC — of type List Item ID for storing the IDs of the tasks created for collecting data from the users. This is shown in Figure 22.24.

  10. After you create the workflow variables, click Next in Workflow Designer.

  11. Specify a name for the first step. As shown in Figure 22.25, this step requires that you run all the actions in parallel.

  12. Click the Run All Actions in Parallel menu option. This ensures that all the users are simultaneously sent the tasks for collecting newsletter content.

    Figure 22.23. Setting initial settings for the NewsLetters workflow

    Figure 22.24. Creating workflow variables for storing IDs of tasks assigned to users for data collection

    Figure 22.25. Running all actions in a step in parallel
  13. Choose Actions More Actions and then choose the Collect Data from a User workflow action. This shows the Collect data from this user (Output to Variable: collect) action sentence in Workflow Designer. You use this action to send the users task items for collecting newsletter data.

    NOTE

    The workflow is paused until all the task items have been completed.

  14. Click the data hyperlink in the action sentence to open the Custom Task Wizard. This wizard allows you to create a task that can be assigned to a user for collecting data. The task can have custom fields that map to input boxes, which the user can fill to submit data.

  15. Read the information on the Welcome screen on the Custom Task Wizard and then click Next.

  16. As shown in Figure 22.26, type a name and description for the task for easy reference later in the workflow.

    Figure 22.26. Typing the name and description of the task in the Custom Task Wizard
  17. Click Next.

  18. Click Add to open the Add Field dialog box, create a field called ContentSalesA of type Multiple lines of text, as shown in Figure 22.27, click Next, and then click Finish.

    Figure 22.27. Creating fields in tasks by using the Custom Task Wizard
  19. Click Finish to complete the Custom Task Wizard and return to Workflow Designer.

  20. Click the this user hyperlink to open the Select Users dialog box and then specify the user to whom the task should be assigned.

  21. Click the Variable: collect hyperlink and select the workflow variable SalesA. It's important to understand that Collect Data from a User workflow action returns the List Item ID of the task that's assigned to the user. You use the workflow variable to store this List Item ID for future use in the workflow. The completely configured workflow action is shown in Figure 22.28.

  22. Using previous steps, configure two more Collect Data from a User workflow actions for the Sales B and Sales C department. For this exercise, you can name the tasks TaskSalesB and TasksSalesC and the fields ContentSalesB and ContentSalesC. The completed set of actions is displayed in Figure 22.29.

  23. Click the Add workflow step link in the right pane to add a new workflow step, type a name for the workflow step, and then choose Actions More Actions to choose the Update List Item workflow action. The action sentence for this action is Update item in this list.

  24. Click the this list hyperlink to open the Update List Item dialog box, keep Current Item selected in the List dropdown menu, and then click Add. The Value Assignment dialog box opens.

    Figure 22.28. Completed Collect Data from a User workflow action
  25. In the Set this field dropdown, select ContentSalesA, click the fx button to open the Define Workflow Lookup dialog box, and then specify a lookup query to locate the content that the user submitted in the task that was assigned in the previous step. Always keep in mind that at runtime, the workflow can't proceed to this step (CollateData) until all the tasks in the first step (CollectDataFromPOCs) are completed.

  26. To implement the lookup query "Select ContentSalesA field in the Task list item whose List Item ID is equal to the value stored in the Sales A workflow variable" by using the Define Workflow Lookup dialog box, in the Lookup Details section, select Tasks in the Source dropdown menu and ContentSalesA in the Field dropdown menu.

  27. In the Find the List Item section, select Tasks:ID in the Field dropdown list box and then click the fx button next to the Value text field. Another Define Workflow Lookup dialog box opens.

  28. In this Define Workflow Lookup dialog box, select Workflow Data in the Source dropdown menu, Variable: SalesA in the Field dropdown menu. This is shown in Figure 22.30.

  29. Click OK. The complete lookup query described in the previous steps is shown in Figure 22.31.

    Figure 22.29. Creating multiple Collect Data from a User actions for collecting data from multiple users

    Figure 22.30. Defining a complex lookup query by using the Define Workflow Lookup dialog box
  30. Click OK twice to complete the field value assignment.

  31. Repeat the previous steps to create value assignments for the ContentSalesB and ContentSalesC columns in the NewsLetters list and then click OK to return to Workflow Designer. The completed Update List Item dialog box should look as shown in Figure 22.32.

    Figure 22.31. The completed workflow lookup query
  32. Check the workflow for errors and then click Finish to complete the workflow and deploy it to the SharePoint site.

In the SharePoint site, you can now initiate the workflow by creating a new item in the NewsLetters list. The workflow should create three task items and then assign them to the specified users. As shown in Figure 22.33, when the user edits the task, he or she is given a choice to complete the task by clicking Complete Task. When all the tasks are completed, the workflow proceeds to the second step and then updates the list item created in the NewsLetters list with the data collected via the tasks from the users.

Figure 22.32. The completed Update List Item dialog box for the NewsLetters workflow

Figure 22.33. The completing task in the SharePoint site user interface

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.19.174