Chapter 12. Advanced Workflows

WHAT YOU WILL LEARN IN THIS CHAPTER

  • Generating workflow designs using Visio Premium 2010

  • Visualize a running workflow using Visio Graphics Services

  • Modifying Workflow Forms using InfoPath 2010

  • Working with Globally Reusable Workflows

  • Exporting Reusable Workflows

Chapter 11 laid out the fundamentals of SharePoint Designer 2010 workflows. Building on that knowledge, this chapter shows how SharePoint Designer 2010 integrates with Visio 2010 and InfoPath 2010 to provide a complete solution to model the workflows and design dynamic user interfaces.

The last part of this chapter dives into strategies of packaging and deploying reusable workflows and shows how you can scale out your workflows to be used throughout your company.

MODELING WORKFLOWS USING VISIO 2010

The Microsoft Visio application has served a great role in the past, helping to visualize complex information such as network diagrams, maps, and floor plans. Now, the same functionality comes to SharePoint 2010. The designer surface for Visio 2010 can be used to model and visualize your workflows

A business or process analyst who understands business processes would be the ideal candidate for using this functionality. The analyst might prefer to use this method to sketch out the model of the workflow and then hand it to an IT professional or an owner of a SharePoint site to automate the processes in SharePoint. On the flip side, when an IT professional or site owner receives a workflow created in Visio, the visual nature of the workflow makes its intent self-evident and becomes a sort of contract of what is agreed to be the scope of the processes being implemented.

The following sections explain how the built-in functionality in Visio 2010 facilitates the workflow modeling in SharePoint 2010.

Exploring the Visio 2010 SharePoint Workflow Stencils

In SharePoint Designer 2007 days, there was no way to visualize workflows created in the workflow designer environment. When the workflows became complicated, getting a bird's-eye view of how all the workflow pieces fit together was very difficult. To solve this problem, SharePoint Designer and Visio teams joined forces. Microsoft Visio Premium 2010 ships with the SharePoint workflow stencils, containing the shapes for all standard workflow activities—conditions and actions (the Standard and Professional versions of Visio do not have this functionality)—that you can use to design a workflow. Then, you can export this workflow in a format that's understood by and imported in SharePoint Designer 2010.

When you start the Visio Premium 2010 application, you can find the Microsoft SharePoint Workflow template under the Flowchart template category. Upon selecting this template, the stencils showing the workflow shapes appear as shown in Figure 12-1.

Figure 12-1

Figure 12.1. Figure 12-1

Building the Visio Workflow

Three stencils contain the workflow shapes:

  • SharePoint Workflow Actions

  • SharePoint Workflow Conditions

  • SharePoint Workflow Terminators

You must place the Start and Terminate objects in the SharePoint Workflow Terminators stencil on the design surface to designate the starting and ending points of the workflow design. Then, you can place conditions and actions in the middle of these terminators as needed to design the workflow logic. The design interface in Visio 2010 expands automatically to another page if more space is needed for the design. Visio 2010's features, such as themes and auto alignment, can be utilized for enhancing the look and feel of the workflow diagram as needed.

No support exists in Visio 2010 for creating logical workflow steps or configuring the rules of each condition and action placed in the designer environment. These things are taken care of after you import the workflow in SharePoint Designer 2010. Also, when building a SharePoint workflow, you can only utilize the shapes in the stencils mentioned earlier. Non-SharePoint shapes from other stencils in Visio 2010 are not supported and produce an error when you try to export the final workflow.

After you finish building the workflow, you must validate it. The Process tab (see Figure 12-2) in Visio 2010 provides the option to check your diagram for any logical errors.

Figure 12-2

Figure 12.2. Figure 12-2

The Check Diagram button works with built-in rules for SharePoint workflow functionality that check the validity of the diagram. This allows the diagram designer to check for any common errors, such as loose connectors in the workflow.

The following exercise walks you through building a workflow in Visio 2010, then validating it and exporting it.

WORKING WITH VISIO 2010 WORKFLOWS IN SHAREPOINT DESIGNER 2010

Both Visio Premium 2010 and SharePoint Designer 2010 applications can import and export the VWI file. This section discusses how the workflow in the VWI file is handled within SharePoint Designer 2010.

Importing Workflows in SharePoint Designer 2010

To start the workflow import process in SharePoint Designer 2010, go to Workflows in the navigation pane and click the Import from Visio button in the ribbon. This starts up the Import Wizard that asks you to browse to the VWI file that you would like to import. After selecting the file, choose the type of workflow to import it as. The choices you have are List or Reusable Workflows, so you can choose either to attach this workflow to any list or library on this site directly or import it as a reusable workflow and choose a base content type for it.

The following Try It Out shows the import process in SharePoint Designer 2010.

Configuring and Publishing the Workflow

You must configure the actions and conditions in a workflow in SharePoint Designer 2010. The exercise in the last section showed how to import a workflow into SharePoint Designer 2010. After importing the workflow, you can use the workflow elements in the workflow designer environment (discussed in Chapter 11) to further enhance the workflow. The following exercise provides an example of configuring the imported workflow.

Visualizing a Workflow Using Visio Visualization

Visio Services, a new feature of SharePoint 2010, provides Visio functionality at the server level. Visio Services lets you view Visio diagrams in the browser without the need for the Visio application on your client machine.

Visio Services is integrated into the SharePoint workflow functionality. Users can view the visual status of any running workflow that has the Visio visualization turned on. A Visio 2010 diagram of your workflow is automatically created and displayed in a Visio 2010 web part on the workflow status page. This visualization shows the exact status of the current stage of the workflow. For this functionality to work, SharePoint server must be running Visio graphics services (controlled through SharePoint Central Administration). An image of a sample Visio visualization is shown in Figure 12-9.

Figure 12-9

Figure 12.9. Figure 12-9

The Visio diagram renders in full fidelity in the browser if the machine being used has Microsoft Silverlight installed. If it does not, then the diagram renders in PNG format.

The visualization of a workflow has to be turned on individually for each workflow that you want Visio Services to process. In the workflow settings page of a workflow is a checkbox labeled "Show workflow visualization on status page." This checkbox must be selected before the workflow is published for the visualization to be generated as part of the workflow history page.

The next exercise shows how to configure the visualization of SharePoint Designer 2010 workflows.

Exporting the Workflow

The workflow settings page for every list and reusable workflow has an Export to Visio button on the ribbon. This means that you can export the design of any list or reusable workflow (site workflows are not supported by this functionality) to visualize in Visio Premium 2010. When importing a workflow in Visio 2010, if the workflow file is already open in Visio 2010, the diagram will be updated to show any changes made in SharePoint Designer 2010. If the diagram file is not open, it will make a new diagram based on the workflow.

One of the advantages of taking the workflow to Visio 2010 is to visualize the processes better. You might want to store the workflow as a Visio diagram so that the visual depiction of the workflow processes is communicated to all stakeholders and so that everyone is clear on what is being implemented.

You can make as many roundtrips as you want between SharePoint Designer 2010 and Visio Premium 2010 with no loss of data or functionality. In other words, none of the rules, steps, variables, and all other configured workflow elements are lost going back and forth between the two applications.

The SharePoint object model provides the ability to create new workflow activities using Visual Studio. You can also buy activities from third-party vendors and plug them into SharePoint. The question then becomes: if new activities are designed and installed in SharePoint, and then used in a workflow that's imported in Visio Premium 2010, how will these activities surface? The answer is that Visio 2010 will show these custom activities as generic box shapes, because it will not know how else to present them. However, the good news is that you will not lose any configurations made to them in SharePoint Designer 2010.

CUSTOMIZING WORKFLOW FORMS WITH INFOPATH 2010

Microsoft InfoPath 2010 provides a robust and powerful environment in which to create electronic forms. Chapter 9 is devoted to discussing how InfoPath 2010 works and the integration points of InfoPath in SharePoint. This section discusses InfoPath form integration within SharePoint Designer 2010 workflows.

SharePoint Designer 2010 workflows make ample use of forms to interact and gather data from users. These forms are created automatically by a workflow at the time it is published. SharePoint Designer 2010 generates three types of workflows automatically:

  • Initiation form—This form is presented to the user when the workflow is started manually on a list or library item. If any initiation form parameters are declared for the workflow, then they show up on this form. The user must then provide input. If no initiation form parameters are declared, then the form only contains a Start and a Cancel button.

  • Task form—Workflows often contain actions that create tasks in the Tasks list on the site. When users interact with these tasks, they are presented with this form. If custom form fields are defined for the task in the workflow, then these fields appear on the task form.

  • Association form—A reusable workflow makes use of association columns (fields). These columns (or fields) are added to the list when the workflow is added to that list. An association form enables you to associate fields with a reusable workflow so that the fields will be available when you design and run the workflow.

Note

Initiation forms, form parameters, and association columns are all topics covered in Chapter 11.

When you publish a workflow in SharePoint Designer 2010, the appropriate forms automatically get generated. You can modify workflow forms after they already exist as part of the workflow. These forms cannot be generated from scratch starting from InfoPath. These forms are visible in the Forms section of the workflow settings page, as shown in Figure 12-13. The XSN extension on these forms clearly indicates that these are InfoPath forms.

Figure 12-13

Figure 12.13. Figure 12-13

To modify these forms, click on the appropriate form to open it in InfoPath 2010. You can take advantage of all the features of InfoPath 2010 (for example, page layout design, data validation, conditional formatting, and more) to enhance this form further. When you are done with your enhancements, simply click the File button and then the Quick Publish button to publish the form back to the workflow from which it came.

The next exercise walks you through customizing a workflow form in InfoPath 2010.

For all of this functionality to work as described in the preceding exercise, you need the InfoPath 2010 application on the client machine to modify your forms. Also, at the server level, you must be running SharePoint Server (Standard or Enterprise). If you are running SharePoint Foundation 2010, the workflow forms that get generated in SharePoint Designer 2010 are ASPX forms, which means these are ASP.NET forms that can be modified within SharePoint Designer 2010, but not in InfoPath 2010. To see the differences between customizing a form using InfoPath 2010 and SharePoint Designer 2010, you can watch the videos at www.sharepoint-videos.com.

BUILT-IN GLOBAL WORKFLOWS

SharePoint Server ships with five built-in workflow templates: Approval, Collect Feedback, Collect Signatures, Disposition Approval, and Three-State. You can start using these directly in your Internet browser by accessing them through any list or library's workflow settings page.

Three of the most popular built-in workflows (Approval, Collect Feedback, Collect Signatures) are built as declarative globally reusable workflows in team sites. An additional workflow called Publishing Approval, similar to Approval workflow, is available when you are working in publishing sites to approve publishing pages. These workflows are available to be fully customized, using SharePoint Designer 2010, by the owner of the top-level site of the site collection.

Note

If you make changes directly to a built-in workflow, you are modifying that workflow for everyone in the site collection. That means that your built-in workflows in this site collection would work differently from the ones in other site collections, thus potentially confusing your end users running the same name workflows, but getting different results in two different site collections.

To avoid this situation, you can make a copy of the workfl ow instead and give it a unique name before modifying it and publishing it to be used globally throughout the site collection.

You can also copy any of these workflows and create a new one with your own custom modifications. You can do this within any site of the site collection. In SharePoint Designer 2010, select the workflow you want to copy and click the Copy and Modify button on the ribbon. This creates a reusable workflow local to that site. After you have made the modifications, then publish the workflow to the site.

Creating New Globally Reusable Workflows

The three globally reusable workflow templates mentioned earlier are available throughout the site collection. You can also create new globally reusable workflows. However, you must have Full Control permission at the top-level site to make this happen.

You can publish any reusable workflow at the top-level site as a globally reusable workflow by going to the workflow settings page and clicking on the Publish Globally button on the ribbon. Publishing a workflow globally places it in the Global workflows catalog, making it reusable on every site within the site collection and visible to all users.

The following exercise shows how you can create a globally reusable workflow.

Using the Task Process Designer

Two of the three built-in global workflows that you can customize are built with actions available under the Actions button, as shown in the following table:

ACTION

BUILT-IN WORKFLOW

Start Approval Process

Approval

Start Feedback Process

Collect Feedback

The third workflow, Collect Signatures, uses a slight variation of the Start Feedback Process action. Also, another action, Start Document Set Approval Process, has the process design that's based on the Start Approval Process action, with the exception that this action works on whole document sets instead of a single document.

These workflows are all completely event-driven, and all the important events in the workflows are available to be customized within the Workflow Editor using the Task Process Designer. Think of the Task Process Designer as a workflow designer within a workflow designer. Each task in the process or the process as a whole can be customized using the Task Process Designer. Figure 12-20 shows the Workflow Editor interface of the Approval workflow. It also shows the Task Process Designer environment that you can enter by clicking on the Approval link in Start Approval Process action.

Figure 12-20

Figure 12.20. Figure 12-20

The next exercise walks you through copying the Approval workflow and customizing it and deploying it onto a site.

EXPORTING WORKFLOWS AS A PACKAGE

In the preceding sections, you learned how to create reusable workflows that you can use within a site or even publish globally so they can be used throughout the site collection. SharePoint Designer 2010 also supports exporting a reusable workflow as a package so that it can be deployed to another site collection or further extended using Visual Studio.

Packaging up a reusable workflow is a simple one-step process executed from the workflow settings page of the reusable workflow. At this page, clicking on the Save as Template button on the ribbon packages up the reusable workflow in a WSP file (SharePoint solution package) and automatically stores it in the Site Assets library of the site, as shown in Figure 12-25.

Figure 12-25

Figure 12.25. Figure 12-25

After you have the file in the Site Assets library, you can export it to your hard drive or file share to transport it as necessary. In SharePoint Designer 2010, click Site Assets in the navigation pane. You can select the WSP file (if the WSP file is not there, refresh the page) and click the Export File button on the ribbon to start the export process.

The following sections explain what you can do with this WSP file after you export it.

Deploying a Workflow Package to a Site Collection

A file with a .wsp extension is referred to as a SharePoint solution file in SharePoint. This file is usually generated by developers and bundles within it components such as features, site definitions, and more.

SharePoint Designer 2010 also has the capability to produce a SharePoint solution file containing a reusable workflow, as shown in the previous section. This file has a .cab-based format but a .wsp file extension. In fact, if you change the file extension of a WSP file (containing a workflow) to CAB temporarily and then double-click on it to open it, you will see the contents of this package are similar to what's shown in Figure 12-26.

Figure 12-26

Figure 12.26. Figure 12-26

You can use the WSP solution file to transfer reusable workflows created in one site collection to another. For example, workflows created in a development environment can be packaged and then deployed to the production environment.

The following exercise walks you through the process of packaging up a reusable workflow as a WSP file and then deploying it to another site collection.

Importing a Workflow Package in Visual Studio

Visual Studio 2010 provides a project template named Import Reusable Workflow. This project understands the structure of the packaged WSP file containing the reusable workflow and lets you point to and import the solution file into the Visual Studio environment, as shown in Figure 12-29.

Figure 12-29

Figure 12.29. Figure 12-29

The story here is that a site administrator or a designer would create the reusable workflow initially in SharePoint Designer 2010, package it up into a solution file, and then pass it on to a developer, who can import it into Visual Studio and extend it as necessary with code. This process is also detailed in an MSDN article located at http://msdn.microsoft.com/en-us/library/ee231580.aspx.

In concept, this is a great idea and provides hope for a rapid development solution that involves the business owner and the developer working side by side. However, before moving forward with this idea, consider the following facts:

  • A single action in SharePoint Designer 2010 may render as dozens of activities in Visual Studio 2010.

  • Workflows with large numbers of activities in Visual Studio 2010 are not easily manageable. The design surface just isn't designed to manage workflows of 100 activities or more, so it seems a bit unwieldy.

  • Workflows transitioned to Visual Studio 2010 cannot be run as declarative workflows any longer and, therefore, must be deployed as farm solutions.

A much larger discussion can be had here from a developer's perspective as to the pros and cons of using this method. Because this is not a book focused on SharePoint development, the discussion of this methodology stops here. You are encouraged to experiment within this area to determine whether this functionality could be useful for your needs.

SUMMARY

This chapter exposed you to the advanced workflow features in SharePoint Designer 2010. You learned how Microsoft Visio, InfoPath, and SharePoint Designer teams have joined forces together to enable these systems to build workflows and interactive forms, and to visualize running processes.

Business analysts can use Visio Premium 2010 to model the processes in a workflow then pass it on to developers or power users, who can import these processes into SharePoint Designer 2010 and configure the workflow further. Also, Visio Services plays a major part in being able to visualize the path and history of a workflow. Furthermore, InfoPath is used by form designers to extend the functionality provided in the default forms that the workflows in SharePoint Designer 2010 create automatically.

The second part of the chapter discussed the opportunities to package up and deploy reusable workflows in a variety of ways—global to a site collection, exported to another site collection, and imported in Visual Studio. This is a major step in making your workflows truly scale throughout your enterprise systems.

Quite a bit of knowledge was presented in the last two chapters on workflows. Nevertheless, the author advises you to continue the journey and keep learning and discovering new ways that you can take advantage of the workflow systems available in SharePoint 2010.

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

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