Friday, October 28, 2011

Why I love reusable workflows in SharePoint 2010

Jeremy Williams

One of the most fascinating things (to me) about software development and version upgrades is the relationship between new features and (to what level) of marketing those features get…  For instance, if I asked anyone on the street (let’s call it SharePoint Lane for fairness) to name some of the new features in SharePoint 2010 I’d probably hear stuff like: Managed Metadata, Business Connectivity Search, Social Computing, FAST Search…  Don’t get me wrong, these are all very cool and helpful features, but there’s other cool features lurking beneath the marketing covers of SharePoint.  And, just as I’m sure you’ve already guessed, I’m going to be talking about Reusable Workflows today!

So, what is a reusable workflow anyways?  You know when you commission a brand new document library, and you just want to add an Approval Workflow to that list content type?  When you click through to do that, what you see in the workflow-picker list is a reusable workflow!  The nice thing about reusable workflows is that you have the option to make them very generic, or very specific based on how you set it up(and your accompanying taxonomy). 

So I’ll shift gears from my pie-in-the-sky-speak here over to a real scenario:

Problem: I want to make a view filter by Content Type so that I can get alerts on certain content types in a library

Issue: Turns out that alerts don’t like to work for views based on System-Columns (like content types) http://chanakyajayabalan.wordpress.com/2010/03/11/no-able-to-set-alerts-for-some-views-in-sharepoint-list/

Solution – Brief: The quick and easy solution is just to add a column to each Content Type in question, hard-code a value in there, and then filter on that value.  This will certainly get the job done, but I like to over-complicate and bullet-proof things a bit more…  As such, I’m going to create a reusable workflow, attach it to some content types, and then filter on my own workflow-set column.

Solution – Walkthrough:

  1. I’m going to set up my taxonomy for this situation; this includes one column of type: Single line of Text.  I called this column, “Filter CT”.
  2. Next, I’m going to open up SharePoint Designer 2010 and make my reusable workflow.  After opening up the appropriate site, press ‘Reusable Workflow’ under the New grouping of the ‘Site’ ribbon tab.
    image
  3. Go ahead and name your workflow, type a description if you’d like, and choose whether you’d like to filter on Content Type.  For my situation, I just chose the ‘All’ Content Type selection.  This will minimize the columns I get ‘for free’, but will maximize the utility of my workflow.  Once you’re ready, go ahead and press Ok to create your workflow and get into the visual design area.
    image
  4. To get access to your custom column, press the image button on the ribbon:
  5. Press ‘Select Site Column’ and scroll until you find your column created in Step One.  Select it and press Ok (twice) to get back to the workflow design area.
    image
  6. Now you’ll have access to your column from the Workflow Design Area.  Go ahead and set the logic to the screenshot below, and then Publish your workflow:
    image
  7. Alright, we’re done in SPD, so head on back to SharePoint…What we’re going to do now is navigate to the Site Content Type area…  We’re going to be making two content types (Disney Document and Warner Bros Document <—Yeah, I’m not creative today).  The content types will be identical except in name, and should include the custom column you made in step 1.  [Note: The right thing to do here is create three content types, the first would by your Theme Park Base Document content type, and you’d then create the Disney/Warner Bros Content Types to inherit the Theme Park Base Document.  However, since I was just doing a Proof of Concept, I was lazy :-)]
    image
  8. Then, to make the workflow fire automatically, press on the Workflow Settings link, click ‘Add a workflow’ and configure it similarly to:
    image
  9. Now, add those content types to your library, add some documents of each content type, and then create two views that filter based on your Filter CT value.  For my example, I have 1 of each document:
    image
  10. Here’s my view of just Disney Documents:
    image
  11. And to finally solve our problem, I can make an alert based on the Disney Content Type (as seen below):
    image

Conclusion: What I just walked through is a very specific, and somewhat simplistic use of the reusable workflow model.  The reason I love reusable workflows is that you get all of the power of workflow, and you can reuse that over and over across your SharePoint Site Structure.  I hope this post has been helpful, thanks!

 

Background: Much of the inspiration for my posts come from issues I see our clients facing and/or discussions I have with my esteemed coworkers.  For today’s post, I’d like to thank and credit Jonathan Rupp and Kim Frehe, as the topic I just discussed calls out some of their problems, solutions, and scenarios as it relates to this post. 

Loading Next Article