Introduction to Visio Services in SharePoint 2010

In this blog post article, I will show you guys how to develop a basic SharePoint workflow using Visio. As part of SharePoint 2010, Microsoft introduced a new feature called Visio Services. This Service Application component allows you to visualize and publish business process diagrams into the SharePoint Context. Quite frankly, this is probably the feature that got me the most excited when I first saw all that SharePoint 2010 had to offer over its MOSS predecessor. 

Developing workflows using Visio is something that everybody is familiar with. Microsoft has really put a lot of emphasis on simplifying the users’ experience with their 2010 release of SharePoint. There have already been several integration points between some of the office suite that I call the “Core Office Clients”, such as Word, PowerPoint, and Excel with the 2007 version of the product. This time around, Microsoft built on the integration of the “Extended Office Clients”, such as Access, Project, OneNote, Visio, and the newly born SharePoint Workspace.

Enough talking, let’s get to the meat of this article. In order for you to start developing your SharePoint Workflows in Visio, you will need the following tools installed on your client machine:

  • Microsoft Visio 2010 Premium or Professional
  • SharePoint Designer 2010;
  • SharePoint Server 2010;

Note that the Visio Services component only comes with the SharePoint Server version; the SharePoint Foundation package doesn’t include these components. Also note that only the premium and pro versions of Visio will allow you to publish diagrams over to your SharePoint Server. SharePoint Designer is also a must to accomplish the task at hand. Visio allows one to map processes into a diagram, but SharePoint Designer is required to put the logic into the different Workflow boxes.

Let’s start by opening Visio. Upon opening the program, you will be presented with the Template Selection screen. The template that allows you to create SharePoint workflows is located in the Flowchart category. You need to go ahead and select that category. Simply click the following icon:

Inside that category, you should see the Microsoft SharePoint Workflow as an option, click on it to select it:

Then click on the Create button in the right area. Doing this will automatically launch a new canvas, and you’ll see SharePoint stencils appear in the toolbox.

The two most important stencils that every SharePoint Workflow should have is the Start and Terminate states.

Go ahead and drag each one onto the drawing area. Now, that we have the start and end states specified, we need to add the meat of our workflow. For this example, we will assume we want to map a business process where the user wants a new task asking for approval to be sent to a user’s manager every time a new item is added to a document library. For the demo’s purpose, we will only handle the case where the manager’s approves the document, and won’t even bother adding logic for the case where it would be rejected.

The first thing we want, is to be able to give the user who initiated the workflow some feedback as to where in the queue of the approval process the document sits. What we want to do for this is to set the workflow’s status. This status will be displayed back to the user besides his document entry, so it will be very obvious what step of the approval process the document in in. The next stencil we need to insert is located under the SharePoint Workflow Action sub category. It is the Set workflow status shape. Drag and drop that shape onto the drawing area, and add an incoming connection to it starting from the Start state shape. You can rename the shape to give more insights as to what we expect the workflow to do:

Your workflow should now look like mine above. The next shape to add is the Assign to-do item one, which tells the system to assign a new task to a user. Next, make sure all shapes on the drawing area are connected in a sequential order. The final diagram should look like the following:

Now that our diagram is completed, we want to ensure it is a valid SharePoint Workflow. Visio now includes a workflow validator feature in the Ribbon, under the Process tab. By clicking the Check Diagram button, Visio will automatically check you workflow for problems.

If no errors are detected, the following message will pop-up:

If you see this message, you are good to go. Otherwise, you probably want to re-run through my article to make sure you got all steps right. Assuming you got the successful validation message above, you are now ready to export your diagram. To do this, simply click on the Export button also located under the ribbon’s Process tab.

Clicking this button will ask you to save the SharePoint Workflow locally as a Visio Workflow Interchange (VWI) format. Make sure you save the file somewhere you have access to.

We now need to add some meat to the workflow skeleton, time to bring up your new best friend, SharePoint Designer 2010. From the interface, you want to open the site that contains the list on which you want your workflow to run on. My recommendation is always to browse to your SharePoint web site via the web browser and to select the Edit in SharePoint Designer option from the Site Actions menu, assuming the option was enabled at the farm level from Central Admin, which it should be by default.

For the purpose of this exercise, I’ve created a new Document Library called “Documents for Approval”. This is the list I will be attaching my workflow onto. It only contains the default out-of-the-box Document library columns.

With SharePoint Designer opened, select Workflows from the left menu:

You’ll notice that the ribbon automatically changes selection, and will see several workflow related options appear up there. The one we are interested in is the Import from Visio one. Go ahead and select that option, doing this will ask you to select a VWI file.

Browse to the file you’ve created from Visio, and click Next. On the following screen, you are asked to give your workflow a name, and to select what list to associate it with. Name the Workflow “Introduction to Visio Services”, and select whatever list you want your workflow to be associated with. In my case, I went and selected my Documents for Approval list I had previously created. After you’ve entered the required information, click on Finish.

After clicking the button, you are automatically brought to the Edit Workflow screen. In the main area of SharePoint Designer, you should now see that various actions you’ve specified in your Visio Diagram.

By default, the workflow is configured to set the Workflow’s status to Canceled. If you remember correctly, in our diagram we mentioned that we were going to set the workflow’s status to Task Assigned. To do this, simply click on the underlined Canceled link, and type in the appropriate status. Moving on to the second option, we need to specify details about the task we want assigned to the user’s manager. Clicking on the a to-do-item link will automatically launch the Custom Task Wizard Screen:

From that screen, click Next. On the second screen, we need to enter a name and a description for the task to be assigned. In the Title field, enter Review & Approve Document, and in the Description box enter You need to review the user document, and complete this task to approve the document. Once the information has been properly entered, click on Finish.

We now need to tell the workflow who to assign the task to. Click on the these users link to open the Select Users dialog box. In there, you’ll notice the option People/Groups from SharePoint site…, click on it. In the next dialog box, simply type in the name of the manager’s responsible for approving the documents. In my case, I will select myself as the manager. Once the user is selected from the list, click on Add>> and then on OK.

Back on the previous screen, simply click on OK.

Your workflow actions should now look like the following:

The next step is to set the workflows setting to let SharePoint know when to start it. Switch to the Workflow Settings screen by clicking the Workflow Settings button from the ribbon.

We want to tell the workflow to start automatically as soon as a new item is added or whenever an existing one is modified. From Start Options area, uncheck the Allow this workflow to be manually started checkbox, and check both the Start workflow automatically when an item is created and the Start workflow automatically when an item is changed.

Now here comes the part where you guys will witness the real power of the Visio Services. We want to tell SharePoint to let us visualize the current state of a workflow at any time during the process execution. To do this, we need to check the Show workflow visualization on status page checkbox from the Settings section.

If this option is grey Shaded, you need to go back to your SharePoint site and ensure you have enabled the SharePoint Server Site Collection Enterprise features. Once that is done, simply close and re-open SharePoint Designer’s.

Let’s publish this workflow back onto our SharePoint workspace. To do this, all you have to do is click on the Publish button from the Ribbon, and wait for it to be deployed.

Back to our SharePoint site, navigate to the document library onto which the workflow has been attached, and add a new document to it. After a couple of seconds, and after hitting refresh once or twice, you’ll notice a new column that appeared in the default view. This column shows you the current workflow’s state, which in our case is the default “Task Assigned” value we gave it.

Clicking on the workflow state, will bring you to the workflow status page. Be aware that by clicking this link, you may experience a wide variety of emotions when you’ll see what’s on the other side. Some may start laughing inadvertently, others may start to crying, so other may simply feel like rubbing the furry wall. Guess what’s on that page? Yes you’ve guess right, SharePoint lets you visualize your original Visio diagram, and lets you see exactly where in the approval process we are at. In our case, we are stuck at the Assign a to-do item step, because the workflow is waiting for the manager’s to approve the document before completing.

If you scroll down the page a bit, you’ll see the actual task that was assign to the approval manager.

In order for you to complete the current workflow, simply sign-in as that person and complete the task. To complete the task, simply select “Edit Item” from the dropdown menu beside the Task’s Title, and click on Complete Task on the next screen:

Completing the task will cause the current page to refresh, and you will now be able to see that all steps in our current workflow have completed successfully.

Voilà, that completes our Introduction to Visio Services. Please note that we could have simply opened SharePoint Designer right from the start, and have created our workflow in there. Publishing it over to SharePoint using the same settings specified above would have still generated the Visio diagram on the Workflow Status page, and have allowed you to visualize the status of your current workflow process. Visio simply makes it easier for one to organize his thoughts, and to clearly name shapes to avoid any confusion.

Leave a Reply

Your email address will not be published. Required fields are marked *