758 CHAPTER 25 BUildiNg WorkfloWs iN sharePoiNt 2010 Once you have made the changes, the workflow will be updated. For out-of-the-box workflows this process will update the existing workflow and all running instances, so be careful not to change the workflow is such a way that will negatively affect one of the instances. After editing custom workflows created with SharePoint Designer or Visual Studio, a previous version of the workflow will appear on the workflow settings page, as shown in Figure 25-10. To remove an existing workflow, simply click Remove a workflow, and you can select the workflows for which you would like to Allow instances of the workflow, Deny new instances, or Remove the workflow associa- tion. When you edit a workflow and two or more versions of that workflow are present, it is important to ensure that the previous versions are not allowing new instances. In addition, when no instances are running on a previous version, you should remove them to help keep your settings from being clut- tered. The last set of information you can view is the workflow reports. This can provide activity dura- tion, cancellation, and error reporting on any workflow that is associated with the given list. FIGURE 2510 At the item level, your workflow management options are even simpler. Referencing Figure 25-3, navigate to the workflow settings page for an item. The page will be similar to the site workflows page. On this page you can view the same information. Click on a specific workflow to view informa- tion specific to that workflow instance. You can’t edit the workflow instance or association, but you can terminate the workflow that is running on an item. You can also see the workflow history for an item. This can provide information regarding different steps of a workflow and when they were com- pleted. It can also be used to help troubleshoot or debug any issues with an existing workflow. WORKFLOW TOOLS IN SHAREPOINT DESIGNER 2010 Although we covered SharePoint Designer 2010 in Chapter 22, it is necessary to reiterate the impor- tant pieces specifically related to workflow. After all, when out-of-the-box workflow templates fail to meet your needs, SharePoint Designer 2010 can be used to create more complex workflow solutions. One distinct difference from the out-of the-box templates is that SharePoint Designer is capable of creating a variety of solution types. With the out-of-the-box templates, your options are Workflow Tools in SharePoint Designer 2010 759 fairly limited: Each template is a configurable solution, but the workflow itself cannot be edited via the browser. With SharePoint Designer 2010, you can create and/or utilize the following: Declarative workflows Direct workflow associations Reusable workflows Prototype workflows Edited versions of standard templates WSP files High-privilege workflows Office InfoPath 2010 forms Association columns Site workflows The following sections describe each of these features. Declarative Workflows A declarative workflow is a code-free, rules-based workflow, using conditions and actions to define a business process. The structure is analogous to the way users define rules for their Outlook mail client. Shipping with an extensive set of conditions and actions, SharePoint Designer 2010 is capable of creating a wide range of workflow solutions. And for most cases these capabilities will far exceed your needs. If you find yourself wanting more you still have options. You can add to the out-of-the- box set of workflow tools by creating additional conditions and/or actions you may need, but this requires custom development using Visual Studio. You can also look into third-party solutions that have already laid the groundwork for you by creating extra conditions and actions that might meet your needs. That is the beauty of SharePoint being a platform, more is always an option. Direct Workflow Associations The workflows you have read about so far have all been templates. Obviously, the standard templates ship with SharePoint 2010, but additional template solutions must be created as Features, packaged as Windows Solution Packages (*. wsp) files, installed on the SharePoint server, deployed using STSADM or PowerShell commands, and activated at the appropriate level. In addition, several steps in that pro- cess require highly elevated permissions on the servers and with SharePoint. This is less than ideal for a scenario where you want “power users” designing their own workflows. With SharePoint Designer 2010, you can bypass this whole process and create direct workflow associations to lists, libraries, content types, and sites. In SharePoint Designer 2010, you can select a target for the workflow and then write the workflow directly to it. This capability makes these solutions fast to deploy, and they require fewer permissions than would be needed to install solution packages to the SharePoint server. The downside to these solutions is that they are not considered to be the best option for creating reusable solutions. In other words, if the workflow is something you 760 CHAPTER 25 BUildiNg WorkfloWs iN sharePoiNt 2010 will likely create and use only once, then SharePoint Designer is the way to go. Conversely, if you want to reuse the solution several times, it is recommended that you take a close look at the require- ments and ensure that the workflow is a good fit. You can create a direct workflow association from the browser in SharePoint, as shown earlier in Figure 25-4, or from the client application. To create the solution from SharePoint Designer 2010, follow these steps: 1. Open SharePoint Designer 2010. 2. Once the application loads, you must first open the site you want to work with. To do so, click Open Site or, if you have recently opened this site in SharePoint Designer 2010, it might still be in the Recent Sites list (see Figure 25-11). 3. From the main site page, you can create a direct workflow association by clicking the Site tab List Workflow in the Ribbon (see Figure 25-12). Another option is to click the link for Workflows in the Site Objects navigation section and then click the List Workflow link (see Figure 25-13). 4. After selecting List Workflow, select the list you want to target. 5. Once you have selected the list, enter a name and description for your workflow. For this example, the name will be Workflow 1. FIGURE 2511 FIGURE 2512 FIGURE 2513 Workflow Tools in SharePoint Designer 2010 761 6. When your workflow opens, you will have a wide variety of configuration options to choose from the client Ribbon. For this example you will configure the workflow to e-mail a user after an item has been added. 7. In the Ribbon, click on the Action drop-down menu and select Send An Email. This action will be added to steps area. 8. Click on “these users”. You will be prompted to specify a user to send the e-mail to, enter a value for the Subject line, and enter a value for the body of the e-mail. After you have made your configurations, click OK. 9. Now that the workflow step is set up, click on Check for Errors. This will check the work- flow for any possible errors that will prevent the workflow from working correctly. Any problems will be highlighted in red. If there aren’t any errors, you will get the following mes- sage: The workflow contains no errors. 10. Click Publish. Your workflow is now associated with the specified list. Reusable Workflows The capability to create reusable workflows is new to SharePoint Designer 2010. Previously, by cre- ating quick workflow associations with specific lists and libraries, it was nearly impossible to reuse declarative workflow solutions. The only option was to replicate the solution. Fortunately, Microsoft felt your pain and has added the capability to simply create reusable workflows by attaching them to content types. In addition to creating workflow associations with lists and libraries, you can now create workflow associations with content types. By doing so, any list or library that uses the con- tent type will include items that will be running workflow instances. To reuse the workflow solution, simply enable the management of content types in your list and/or library and add the designated content type. Note that this is not as “reusable” as a workflow tem- plate would be. Depending upon the workflow requirements, a workflow template may still be the best approach when creating a reusable solution, but for a nondeveloper, this is a convenient work-around and an answer to many SharePoint 2007 user requests. Creating a reusable workflow in SharePoint Designer is very similar to creating a list workflow. The main difference is that when you enter the name and description, you must also select a base content type to limit the workflow to (see Figure 25-14). This enables you to reuse the workflow by adding the designated base content type to a list or library. FIGURE 2514 762 CHAPTER 25 BUildiNg WorkfloWs iN sharePoiNt 2010 Prototype Workflows Testing is an important part of any solution building — especially when you think that the current tool may be the cheaper, quicker way to go. However, in the event that it doesn’t work out, it would be nice to have the capability to transfer the current solution in its incomplete state to another appli- cation that you know could finish the solution. With SharePoint Designer 2010, you can do exactly that. With its new graphical workflow designer, you can test your solution; and if it fails to meet the business requirements, you can export it to Visual Studio 2010 for completion. Few applications can offer that level of flexibility. Edited Versions of Standard Workflow Templates A common request that has hounded nondeveloper workflow creators for the past few years is the capa- bility to easily edit the out-of-the-box workflow templates that ship with SharePoint. Organizations often find that the out-of-the-box templates only get them 80% of the way to their business processes. Unfortunately, that leads to one of two options: settling for less or paying to have a custom solution created from scratch. In most cases, a company with a tight budget ends up settling for less than what they want. This dilemma has not fallen on deaf ears. With SharePoint Designer 2010, you can now edit and redeploy the out-of-the-box templates. The options to do this lie within the Ribbon on the applica- tion; one simple click pulls in the template of your choosing. Once you make the changes you want, save them back to the template and you are good to go. The following steps can get you started: 1. Open the SharePoint Designer 2010 application. 2. Open your site. 3. Click the Workflows link on the Site Objects navigation on the left. For this example, we will edit the Approval – SharePoint 2010 workflow template. 4. When the Workflows tab opens in the middle of the page, click the out-of-the- box template you want to edit. You can click the icon next to the workflow link, which will highlight the workflow so that you can click the Edit Workflow link in the Ribbon (see Figure 25-15), or you can click directly on the work- flow link, causing it to open a new designer tab (see Figure 25-16). 5. By clicking on Edit Workflow, the workflow designer will open. You will see the conditions and actions the current workflow design is using. Make the desired changes and then save the workflow. Saving the workflow will save your changes for the next time the out-of-the-box Approval – SharePoint 2010 template is used. FIGURE 2515 Workfl ow Tools in SharePoint Designer 2010 763 FIGURE 2516 A word of caution! One thing to keep in mind when editing out-of-the-box- templates is location. To edit the workfl ow in SharePoint Designer, you must fi rst open it from a site in SharePoint Designer. If you open the top-level site of a site collection and make changes to the out-of-the-box workfl ow template, it will save the changes to the entire site collection and all of its child sites. If you open a web (aka a subsite) of a site collection and make changes, a new version of the work- fl ow will be saved to that site and you will not overwrite the standard template for the entire site collection. In some scenarios, an organization might want to do each of these types of updates, so make sure that you know what change you want to make, and then that will determine where the change needs to take place. WSP Files Unlike the previous ways of creating workfl ows, in SharePoint Designer 2010 you now have the option of saving a reusable workfl ow as a template. By doing so, the template is saved as a . wsp fi le and can be transferred to another SharePoint server or to Visual Studio 2010 for editing. This pro- vides yet another way in which SharePoint 2010 technology enables users to effectively collaborate on solutions — in this case, workfl ows — even if the users have different skill sets and are working in different applications. For more information on WSPs check out lucky Chapter 13. 764 CHAPTER 25 BUildiNg WorkfloWs iN sharePoiNt 2010 High-Privilege Workfl ows The standard workfl ow runs with the permissions of the user who initiated the workfl ow, so if a user submits a document for approval, that approval workfl ow is running with that user’s creden- tials and can perform only those actions that the user would be able to do in SharePoint. This is lim- iting, as in some instances you would like the workfl ow to perform with higher permissions — for example, when using the Copy List Item or Create List Item actions. You may want to copy or create a list item to an archive list or library that has custom permissions so that all users have read-only access. This will be impossible for a standard workfl ow to run. When the copy or create action step is run, the workfl ow will throw an error. Fortunately, a new feature allows you to change the user account that the workfl ow uses. This is known as an impersonation step, and it allows users to create high-privilege workfl ows. After this step is added to your workfl ow, any subsequent actions run as the author of the workfl ow. This is a great advancement for workfl ow creators, and the only restriction is that the user who is creating the workfl ow must have the appropriate access for any condition or action it will perform. However, it is much more secure to give permissions to one user, rather than a whole group of users. In some situations, a designated user account can be created specifi cally for this purpose. O ce InfoPath 2010 Compatibility With SharePoint Server 2010, you can now create SharePoint Designer workfl ows that leverage Offi ce InfoPath 2010 forms. These forms are much easier to create and edit than the previous ASPX forms used in 2007. You can also use the additional conditional formatting and easy branding that is included with the InfoPath client. For users to be able to have this type of integration with InfoPath browser- enabled forms, you must be using SharePoint Server 2010 Enterprise, which has the licensing for Forms Services. This integration is also possible with SharePoint Foundation 2010 and SharePoint Server 2010 Standard, but users will either have to have the InfoPath client installed on their machines or the environment will need to be licensed to support clientless forms. Associated Columns Another innovative feature available with SharePoint Designer 2010 is the capability to create asso- ciated columns. These columns are placeholders for information needed for the workfl ow to run, and will be added to the list or library schema when the specifi ed workfl ow is associated. These can be columns that require user input, or they can simply be a choice column that contains status infor- mation used throughout the process of the workfl ow that defi nes the subsequent steps. However you choose to use them, they provide yet another advantageous feature that enables users to create suc- cessful workfl ow solutions. . must be using SharePoint Server 2010 Enterprise, which has the licensing for Forms Services. This integration is also possible with SharePoint Foundation 2010 and SharePoint Server 2010 Standard,. for this purpose. O ce InfoPath 2010 Compatibility With SharePoint Server 2010, you can now create SharePoint Designer workfl ows that leverage Offi ce InfoPath 2010 forms. These forms are much. browser in SharePoint, as shown earlier in Figure 25-4, or from the client application. To create the solution from SharePoint Designer 2010, follow these steps: 1. Open SharePoint Designer 2010.