Category Archives: SharePoint Workflow

Emailing Daily Task Reminders // Looping in SharePoint Designer Workflow

I wrote up a detailed article a few weeks ago describing how to create a SharePoint Designer workflow that sends a task reminder email on a daily basis.  It’s been published at the new SharePoint Magazine site.  More generally, the article shows how to create a looping structure in SPD.

The magazine has a wide variety of articles including, among other things, very technical stuff, interviews and industry news.  I recommend you add it to your RSS feed.

If you have a product or service to sell, I’d also consider advertising on the site.  It’s off to a strong start with several thousand pairs of eyes looking at it already.  That’s sure to grow.

Lastly, if you’ve been itching to write something and get it out in front of a larger audience, this is a great time and place to scratch it.  

</end>

Subscribe to my blog.

Technorati Tags:

My Latest “In Defense of SharePoint Designer” Article is Available

Mark Miller over at End User SharePoint has posted my latest article about using SharePoint Designer to create great workflow solutions up on his site.  Check it out.

In this article, I talk about the design process and, in greater detail, how to set up a reliable and repeatable test process using SharePoint features (custom lists, site templates).  The article targets End Users, but the approach is good for developers too.

</end>

Subscribe to my blog.

Logging Workflow Activity in SharePoint Designer

Last week, I was working out how to loop and implement a state machine using SharePoint Designer and mentioned, as an aside, that I would probably write a blog post about better workflow logging.

Well, Sanjeev Rajput beat me to it.  Have a look

Saving log data into a custom list seems superior to using the regular workflow history:

  • It’s just a custom list, so you can export it to excel very easily.
  • You can create views, dynamically filter the data, etc.
  • It’s not subject to the auto-purge you get with regular workflow history.

There are some risks / downsides:

  • Many running workflows with a lot of logging could cause too much data to be written to the list.
  • Maybe you *do* want automatic purging.  You don’t get that feature with this approach (without coding).
  • Security is tricky.  In order to write to the list, the user must have permission to do so.  That means that it’s probably not suitable for any kind of "official" audit since the user could discover the list and edit it.  This could be overcome with some custom programming.

</end>

Technorati Tags:

Subscribe to my blog.

The Trouble With Tribbles … err .. KPIs

This past week I finished off a proof of concept project for a client in Manhattan.  While implementing the solution, I ran into another shortcoming of MOSS KPIs (see here for a previous KPI issue and my workaround).

Background: We used SharePoint Designer workflow to model a fairly complex multi-month long business process.  As it chugged along, it would update some state information in a list.  KPIs use this data to do their mojo.

We decided to create a new site each time a new one of these business processes kicks off.  Aside from the workflow itself, these sites host several document libraries, use audience targeting and so forth.  Just a bunch of stuff to help with collaboration among the internal employees, traveling employees and the client’s participating business partners.

We also wanted to show some KPIs that monitor the overall health of that specific business process as promoted by the workflow state data and viewed using the KPIs.

Finally, we used KPI list items that do a count on a view on a list in the site (as opposed to pulling from another data source, like excel or SQL).

The Problem: As you can imagine, assuming we were to carry the basic idea forward into a production world, we would want a site template.  Provision a new site based off a "business process" template.

The problem is that you can’t seem to get a functioning KPI that way.  When I create a new site based on a template with a KPI List and KPI web part, the new site’s KPI data are broken.  The new site’s KPI list points at whatever source you defined when you first saved it as a template.

By way of example:

  • Create a new site and build it to perfection.  This site includes the KPI data.
  • Save that as a template.
  • Create a new site and base if off the template.
  • This new site’s KPI list items’ sources point to the site template, not the current site.

The instantiation process does not correct the URL.

I tried to solve this by specifying a relative URL when defining the KPI list item.  However, I couldn’t get any variation of that to work.

I always want to pair up these "problem" blog posts with some kind of solution, but in this case I don’t have a good one.  The best I can figure is that you need to go in to the newly provisioned site and fix everything manually.  The UI makes this even harder because changing the URL of the source list causes a refresh, so you really have to redefine the whole thing from scratch.

If anyone knows a better way to handle this, please post a comment.

</end>

Technorati Tags:

Mea Culpa — SharePoint Designer *CAN* Create State Machine Workflows

I’ve recently learned that it’s possible and even fairly easy to create a state machine workflow using SharePoint Designer.  Necessity is the mother of invention and all that good stuff and I had a need this week that looked for an invention.  Coincidentally, I came across this MSDN forum post as well.  My personal experience this week and that "independent confirmation" lends strength to my conviction.  I plan to write about this at greater length with a full blown example, but here’s the gist of it:

  • The approach leverages the fact that a workflow can change a list item, thereby triggering a new workflow.  I’ve normally considered this to be a nuisance and even blogged about using semaphores to handle it.
  • SharePoint allows multiple independent workflows to be active against a specific list item.

To configure it:

  • Design your state machine (i.e., the states and how states transition from one to the next).
  • Implement each state as separate workflow.
  • Configure each of these state workflows to execute in response to any change in the list item.

Each state workflow follows this rough pattern:

  • Upon initialization, determine whether it should really run by inspecting state information in the "current item".  Abort if not.
  • Do the work.
  • Update the "current item" with new state information.  This triggers an update to the current item and fires off all the state workflows.

Aside from the obvious benefit that one can create a declarative state machine workflow, all that state information is terrific for building KPIs and interesting views.

It does have a fairly substantial drawback — standard workflow history tracking is even more useless than normal 🙂  That’s easily remedied, however.  Store all of your audit type information in a custom list.  That’s probably a good idea even for vanilla sequential workflow, but that’s for another blog post 🙂

I call this a "mea culpa" because I have, unfortunately, said more than once on forums and elsewhere that one must use visual studio to create a state machine workflow.  That simply isn’t true.

</end>

 Subscribe to my blog.

Technorati Tags:

Use Semaphores in SharePoint Designer Workflow to Prevent Endless Loops

It’s possible to cause an endless loop in a SharePoint Designer workflow.  A common implementation pattern like this causes the problem:

  • Create a workflow and associate with a list.
  • Indicate that it should start on create of new items and update of existing items.
  • A step in the workflow updates a field in "Current Item".
  • Since the current item changed, the workflow starts anew.

To prevent this endless loop, implement a simple semaphore:

  • Add a site column (or column to the list/library if you’re not using content types).
  • Hide it from the edit page (easy to do if a site column via its properties, not as easy if a list column).
  • In the workflow, check to see if the value of the semaphore column is blank.
  • If it is blank, set it to a non-blank value and proceed.
  • If is is not blank, exit immediately.

This can become a fairly nuanced solution, depending on business requirements and so forth, but it’s been a workable pattern when I’ve needed it.

</end>

Technorati Tags:

Subscribe to my blog.

Walk-through: Fix Employee Training Template Available Seats Unregister Bug

As many people know, the Employee Training template provided by Microsoft here has a bug that we can reproduce following these steps:

  • Create a class with a max size of 10 students.
  • Register –> Total available seats properly decrements by one.  Result: 9 available seats.
  • Unregister: –> Bug.  Total available seats should increment by one.  It does not.  Result: 9 available seats as per SharePoint, but in fact, there are 10 available seats.

Solution: Use SharePoint Designer to correct the workflow.

First, open up the site.  The folder list for me looks like this:

image

If we have a look at the "Attendee registration" workflow, we see that there is a step labeled "Enforce seating policy".  It looks like this:

image

This step in the workflow updates the item by incrementing the "Filled Seats" metadata column on the course.  If we pull that up in more detail, we see this:

image

That’s all the information we need to fix the unregistration workflow.

If we flip over to the unregistration workflow, there is no similar workflow step.  Add it as follows:

1: Expand "Attendee unregistration" and open up the XOML (see first screen shot if you’re lost).

2: Add a new workflow variable, "New Filled Seats" of type "Number".

3: Assign a value to "New Filled Seats" as shown:

image

4: Decrement the Filled Seats by 1:

image

5: Update the related Course item:

image

6: Make sure all the steps are in the right sequence.  For me, it looks like this:

image

7: Finish the workflow to re-build it.

8: Test.

</end>

 Subscribe to my blog.

Technorati Tags: ,

Towards SharePoint Technical Design Patterns: SharePoint Designer Workflow + Event Receiver = High Potency Cocktail

One of the emerging patterns I find in crafting SharePoint solutions leverages SharePoint Designer workflow and an event receiver.

Here is a business scenario to put it in context:

  • I upload a document to a doc lib.
  • I kick off multi-step workflow created using SharePoint Designer.
  • At some point during that process, workflow assigns a task to someone (via collect data from user or assign a task).
  • We want to use a KPI to track how long that task is awaiting completion.  The KPI shows green for tasks that are completed or due more than 3 days from now.  It shows yellow if the task is due tomorrow or today.  It shows red if the task is past due.
  • Here’s the kicker: I want the date that drives that KPI to be holiday-aware.

I can’t calculate a holiday-aware due date in SharePoint Designer workflow very easily.  I would have to create a custom action or use a 3rd party tool.  However, it’s easy enough to calculate such a date in an event receiver.  Merge those two together and we get a pattern like this:

  • Define a hidden yes/no site column on the document library labeled "DoCalcualteDueDate".
  • Initialize it to false.
  • At the appropriate time in the workflow (e.g. just before the "collect data" action), assign that value to True.
  • An ItemUpdate() event receiver looks to see if "DoCalculateDueDate" is true.  Since the event receiver runs on every update, "DoCalculateDueDate" is normally false.
  • When workflow assigns DoCalculateDueDate to true, the event receiver calculates the holiday-aware due date.
  • When the event receiver does this calculation, it sets the DoCalculateDueDate flag to false.

In the end, SPD workflow is communicated with an event receiver via the DoCalculateDueDate semaphore and we have holiday-aware due dates that are assigned at the exactly correct moment in the workflow’s life.  SharePoint Designer controls when the due date is assigned but the event receiver performs the actual calculation and assignment.

</end>

Subscribe to my blog.

Observed Behavior: Moving SPD Workflows Within a Site Collection

 

UPDATE: I’ve been researching how to embed a SPD workflow into a site definition.  This MSDN forum chain has some interesting information.  It’s not conclusive, but points to path through the jungle.

I’m giving this post a slightly oddball "Observed Behavior" lead since I’m a little leery of drawing conclusions from it.  SPD workflows are … temperamental.

People are often asking / wondering / fretting over moving SPD workflows from one place to another.  Today, I followed these steps and made these observations:

  • I created a workflow using SharePoint Designer in a site attached to a document library.
  • The associated document library already housed several documents.
  • I saved the site as a template.
  • When I saved the site as a template, I saved the content as well.
  • I created a new site in the same site collection using that template.

At this point, I tried to run the workflow.  It promptly terminated itself with the log message, "Failed on start".

I expected this.  I have low expectations when it comes to moving SPD workflows around.

I continued:

  • Opened the site in SharePoint Designer.
  • Had a peek at the workflow.  It seemed fine.
  • I clicked "Finish".
  • I ran the workflow.

This time, it worked fine.

I’ll add that this workflow used the "collect data from user" action which is a relatively complex action under the hood.

I tentatively conclude that the process of "finishing" the workflow caused SPD to properly associate the SPD workflow with the new document library.  I also conclude the XOML and other XML artifacts are reasonably "loose".  They are not super tightly coupled to the document library.

What does this mean?  Assuming it’s a reliable and reproducible process, there’s at least one rough method we can use to move them around.  I don’t know if this would work if we crossed site collection boundaries or even more drastically, entire new farms (e.g. dev to stage to prod). 

If you’re reading this and inclined, please post a comment or email me your SharePoint Designer migration story.  I’ll gladly update this posting with any insights thus offered.

</end>

Subscribe to my blog.

Technorati Tags:

Quick and Simple: Workflow-only Update Field

It’s often useful to store status information in a custom list such as an approval code which should never be directly manipulated by end users.  This is a common business scenario.  I have been working on a project this year that generates various status and reminder dates via SharePoint Designer workflows that then drive KPIs and generally support time-critical business processes. 

Use a site content type / column to achieve this effect.

Create a site content type with the status column as shown:

image

Note the "Status (for Demo)" field at the bottom.

Next, click on the column name to access the column’s properties.  Select "Hidden (Will not appear in forms)" in the Column Settings section as shown:

image

This removes the field from the standard edit/update forms.  However, it is still available in views, KPIs, the object model and anywhere else you want to use it, including SPD workflow. 

</end>

Subscribe to my blog.