Designing a Workflow Using Visio 2010 Share Point 2010

Visio 2010 includes a new template for creating SharePoint workflows. By using the Microsoft SharePoint Workflow template, designed workflows can be exported from Visio into SharePoint Designer for further configuration. Furthermore, regardless of whether a workflow was created using Visio originally, SharePoint Designer provides the facility to export the workflow in a format that can be imported into Visio for refinement.
NOTEIt’s not possible to create Visio Workflow Interchange files for Visual Studio generated workflows. These workflows do not appear in the Workflows list in SharePoint Designer.

Using the Microsoft SharePoint Workflow Template

Our scenario calls for three workflows: an environmental control procedure, a publishing procedure, and an advert promotion procedure. To demonstrate the creation of workflows using Visio 2010, we’ll implement the publishing procedure. To recap the procedure: New products will be added by the sales department. So that relevant technical information is available, details of the product will be passed to the engineering department, which will update the product record with appropriate details. With these details in place, the marketing department will then be responsible for collating and attaching the appropriate artwork before the product is sent for final approval by the online sales manager. Let’s look at how this can be modeled using Visio:

  1. Open Visio 2010. From the Flowchart template category, select the Microsoft SharePoint Workflow template. Click Create to create a new document based on the template.
  2. The first thing we need to add are terminators that denote the start and endpoints for our workflow. Drag Start and Terminate shapes onto the page, as shown next:
  3. Using the Microsoft SharePoint Workflow Template
  4. Our scenario specifies that the engineering department will provide appropriate technical details for our product record. We want to create a task requesting further information and assign that task to the engineering department for completion. To model this, we can use the Collect Data From A User shape. Click the SharePoint Workflow Actions header, and then drag a Collect Data From A User shape onto the page. Double-click the shape and type the description CollectTechnical Details from Engineering Department.
  5. The next step in our process is to have the marketing department provide artwork for our product record. Again we can model this using the Collect Data From A User shape. This time type the description Collect Product Image from MarketingDepartment.
  6. The final step in our process is to assign the completed product record to the online sales manager for approval. Since we don’t require any content to be added this time, a more appropriate shape to model this interaction is the Assign Item For Approval shape in the SharePoint Workflow Actions stencil. Drop the shape on the page and type the description Assign to Online Sales Manager for Approval.
  7. Now that we have the steps of our workflow laid out, our next step is to connect them using the standard Visio Connector tool on the Home ribbon in the Tools section. Use the connector tool to join up the steps of the process. The completed workflow will look like this:
  8. Using the Microsoft SharePoint Workflow Template
  9. With our Visio model complete, we can create a Visio Workflow Interchange (.vwi) file that can be imported into SharePoint Designer. Select the Process ribbon. Before exporting a workflow, we should check for any errors. Click the Check Diagram button to validate our model. All being well, a dialog will confirm that “No issues were found in the current document.” We can then move on to create the interchange file by clicking the Export button. Name the file by typing PublishingProcedure.vwi.
  10. We’re done with Visio for now. Click the Save icon in the upper-left corner and save the document as PublishingProcedure.vsd.

Implementing a Visio Workflow Using SharePoint Designer
In the preceding section, you saw how to model a workflow using Visio and create an interchange file that can be imported into SharePoint Designer. In this section, we’ll move on to flesh out the logic defined in Visio using the built-in workflow activities available via SharePoint Designer.

  1. In SharePoint Designer, select Workflows from the Site Objects pane.
  2. In the Workflows ribbon’s Manage section, click the Import From Visio button.
  3. Browse to the PublishingProcedure.vwi file that we created in the preceding section. Click Next to import the file.
    Implementing a Visio Workflow Using SharePoint Designer
  4. In the Import Workflow From Visio Drawing dialog, type the Workflow name as Product Publishing. Two different workflow types are available: List Workflow and Reusable Workflow. The main difference between these workflows is that the List Workflow is attached to a particular list and cannot be used by multiple lists, whereas a reusable workflow can be bound to any number of lists or content types. List workflows provide comparable functionality to SharePoint Designer workflows in MOSS 2007. ChooseReusable Workflow as the type, and then from the content types dropdown, select Product. The completed dialog will look like the following illustration.
    Click Finish to complete the import process. Once our Visio model has been imported, SharePoint Designer will create a new workflow named Product Publishing and will automatically open the workflow editor, shown next, where we can complete the configuration of the workflow.
    Implementing a Visio Workflow Using SharePoint Designer
  5. The logic steps from our Visio model have been automatically inserted into our SharePoint workflow, and hyperlinked terms in each step allow us to finalize the configuration. In the Collect Technical Details from Engineering Department step, click the data hyperlink so that we can define exactly what data should be collected. In the Custom Task Wizard that appears, click Next to begin creating a new task.
  6. Name the new task Collect Technical Details. Click Next to add fields for the data in which we’re interested.
  7. Add a field and name it Technical Data. Set the Information Type to Multiple lines of text. Click Next, accept the default columns settings, and then click Finish to add the field.
  8. Click Finish to complete the Custom Task Wizard.

Using Workflow Variables
Now that we’ve created a custom task to capture data, we need a way to retrieve the data that we’ve captured so that we can do something useful with it. As its name suggests, the Custom Task Wizard creates a task with a custom form. When a user completes the form, any data captured is stored in the associated task. The output of this step is an identifier for the task item that was created. As you’ll see later, we can use this to pick up a reference to the task and from there access any data that was captured in our custom form. You’ll remember reading about workflow rules and variables. Since we need to use our task identifier in another step of our workflow, we must create a variable and assign the output to it.

  1. To add a new variable, click the Local Variables button from the Workflow ribbon. Add a new variable named TechnicalDetailsTaskId with a type of List Item Id, as shown next. Click OK.
  2. To assign the output of our Collect Technical Details task to our new variable, click the (Output to collect) hyperlink and then select Variable:TechnicalDetailsTaskId.
  3. Using Workflow Variables
  4. Use the Custom Task Wizard to add a Collect Product Image from Marketing Department step. This time, add a field and name it Product Image of type Hyperlink or Picture and uncheck the Allow Blank Values option in Column settings. Add a variable named ProductImageTaskId to store the output of the task.
  5. Now that we’ve configured our data capture tasks, the only item remaining is the approval action. Click the this item hyperlink to select the items that should be the subject of the approval process. In our case, it should be the Current Item.
  6. With these configuration changes in place, our revised workflow should look like this:

Using Workflow Variables
Using Initiation and Association Forms

You’ll notice that a few properties still need to be configured. These properties contain details of the users to which each task should be assigned. Generally speaking, properties such as these, which are likely to change over time, should be user-configurable—that is, the user should be able to change them without having to edit the underlying workflow. SharePoint workflows provide two forms for user configuration: the Association form, which is presented when a workflow is attached to a list, and the Initiation form, which is presented when a workflow is manually started.

There’s one thing to bear in mind when using the initiation form: it’s not shown if the workflow is started automatically. So, for example, if we created a workflow that was set to start every time an item changed, the initiation form would never be shown. In the case of our workflow, an association form is a more appropriate choice, because it allows us to define parameters that can be set at the list level.

  1. To define a parameter that appears on an association form, click the Initiation Form Parameters button in the ribbon. Add a new field named EngineeringDepartment with an Information type of Person or Group. In the Collect From Parameter During drop-down, select Association (Attaching To A List). In the Column Settings dialog, uncheck the Allow Blank Values option and select the All Users radio button in the Choose From section. Click Finish to add the parameter.
  2. Repeat step 1 and add a Marketing Department parameter and an Online Sales Manager parameter.
  3. To bind these parameters to our workflow actions, click the this user hyperlink. Since we’re binding to a parameter rather than an actual user, select Workflow Lookup for a User. Click Add to configure the parameter binding. In the Lookup for Person or Group dialog, select Workflow Variable and Parameters as the Data source. Our association form parameters can now be selected from the Field From Source drop-down. Select the appropriate parameter and then click OK to complete the binding.
  4. Repeat step 3 to bind all association form parameters to our workflow actions.

Using the SharePoint Designer Lookup Dialog

Although we’ve configured the actions that were imported from Visio, the end result of our workflow in its current state won’t be quite as we expected. Although we’re collecting data from engineering and marketing, we’re not actually attaching that data to our product, it’s stored in the custom tasks only. To fix this problem and achieve the desired result, we need to add a few more actions. Moving the mouse to the end of the list of workflow steps will show an orange cursor. Click the cursor to open a text box that can be used to search for the action that we want to add next. (This cursor appears between each workflow action and before the first action, so we can add actions wherever we need them.)

  1. Type Set f and then press the enter key to insert a Set Field in Current Item action. Configure the field as Technical Details and then click the value hyperlink. Click the fx button to display the Lookup dialog.
  2. You’ll remember that the data entered in our custom task forms is stored in the task. Using the Lookup dialog, we can extract this data using the ID of the task in which we’re interested. Set the data source to Tasks. When a workflow is associated with a list, one of the mandatory parameters is the name of a task list to be used by the workflow for creating tasks. This task list can be referenced using the Tasks data source.
  3. In the Field From Source drop-down, select Technical Data. The column contains the details that a user enters in the custom Collect Technical Details form. Since the data source to which we’re binding contains potentially more than one item, we need to filter it to return only the specific task in which we’re interested. We created variables to store the output of our custom task actions earlier in this, and we can use these variables here to pick up references to the appropriate tasks.
  4. In the Find the List Item section, set the Field to ID and then click the fx button to show the Lookup dialog. In that dialog, set the Data Source to Workflow Variables and Parameters and the Field From Source to Variable: TechnicalDetailsTaskId. Since we intend to use this to look up an item, set the Return Field As to Item Id, as illustrated:
  5. Using the SharePoint Designer Lookup Dialog
  6. We’ve added this action at the end of the workflow when really it makes more sense to attach this data before sending the product record for approval. To move the action up, highlight it and then click the Move Up button on the Workflow ribbon.
  7. Add a new Set Field in Current Item action directly underneath the action. Use the Lookup dialog to attach our Product Image data.
  8. Click Save to commit these configuration changes. We’ve now completed our first workflow using SharePoint Designer and Visio. The finished workflow should look as shown:

Using the SharePoint Designer Lookup Dialog
Using Visio Services to Visualize Workflow State

In addition to the actions that we defined in our original Visio model, we’ve also included a few new actions to attach the captured data to our product item. We can export our updated workflow to Visio so that we can update our diagram with appropriate descriptions for these new actions. Once our model is updated, we can use it to provide status visualization for our workflow.

  1. In SharePoint Designer, select Workflows from the Site Objects pane. Select the Product Publishing workflow from the list.
  2. From the Workflows ribbon, click the Export To Visio button. Save the interchange file as Publishing Procedure.vwi.
  3. Open Visio 2010, and then either open the saved Publishing Procedure.vsd document that we created earlier or create a new document from the Microsoft SharePoint Workflow template.
  4. From the Process ribbon, click the Import button. Browse to the Publishing Procedure.vwi file that we exported in step 2.
  5. The revised workflow will be imported and will update our existing model where appropriate. Add descriptions for the two Set Field In Current Item actions. The first should be Store Technical Data and the second should be Store Product Image.
  6. With these changes made, we can tidy up the layout if appropriate and export our workflow as we did in the preceding section. The completed model should look as illustrated:
  7. Using Visio Services to Visualize Workflow State
  8. Switch back to SharePoint Designer to import the changes. Select the Product Publishing workflow and then click the Import From Visio button in the Workflows ribbon to import the changes. You’ll notice that, this time, SharePoint Designer recognizes that the interchange file relates to an existing workflow, and rather than prompt you for details to create a new workflow, it automatically upgrades the existing workflow with the changes.
  9. To use our Visio diagram to provide status visualization for our workflow, we need to check the Show Workflow Visualization On Status Page checkbox in the Settings section, as illustrated. Click the Save icon in the upper-left corner to save the changes to the Product Publishing workflow.
  10. Using Visio Services to Visualize Workflow State
  11. Before we can use the workflow, we need to publish it. After you publish the workflow, SharePoint Designer will automatically generate any required InfoPath forms. If the workflow being published is already attached to a list or content type, all new instances of the workflow will use the new published version, while currently running instances will continue to use the previous version. To publish our Product Publishing workflow, click the Publish button in the Workflow ribbon.

Associating Reusable Workflows

With our new workflow published, we can now associate it with our Product content type. You’ll remember that when we created our workflow, we specified that it should target the Product content type. Even though we specified this targeting, the workflow isn’t bound to any content type until we specifically bind it. When creating a workflow, the main reason for setting a content type target is to ensure that the fields of that content type are available as values within the workflow logic. For example, we specified Product so that we could make use of the Product Image and Technical Data fields.

  1. To associate our workflow with the Product content type, click the Associate To Content Type button in the ribbon. You’ll notice that the only option available in the drop-down list is Product. Since our workflow targets the Product content type, only content types that are derived from Product or the Product content type itself are valid selections. Select Product to begin the association process.
  2. The association process is performed using the SharePoint user interface. Since we want our workflow to start automatically when a new item is created, check the appropriate start option and then click Next to continue.
  3. SharePoint Designer automatically generates a custom association form based on the parameters that we specified in our workflow. Since we’re using a blank site, we don’t have specific user accounts for each of the three departments. We can usethe built-in Approvers group for the purposes of this demo. Complete the form as illustrated, and then click Save to complete the association.
  4. Figure
  5. To see our new workflow in action, browse to the Products list and add a new item. Once the item is saved, the Product Publishing workflow automatically starts. By clicking the In Progress link in the Product Publishing column, we can see more detail on the workflow progress, including our Visio visualization, as illustrated. We can click the tasks that are created and enter the appropriate information to complete our workflow. Notice that the progress is indicated on our Visio visualization.

Associating Reusable Workflows

NOTEYou’ll notice that the New Item form contains text boxes for each of the fields in our content type. Of course, this is perfectly reasonable in most situations, but in our case, we don’t want the Product Image and Technical Details fields to be populated, because these are completed by the appropriate department. As described in more detail in Chapter, we can easily customize this form to suit our requirements using InfoPath

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Share Point 2010 Topics