Custom actions for reusable workflows

SharePoint Designer 2010 has 2 great new features:
  1. Custom Actions (create ribbon buttons and item menu actions)*
  2. Reusable Workflows (create a workflow once and use it across the site collection)
Custom actions are very simple to create in SharePoint designer - just pick where you want the button (ribbon, item menu etc.), select the action and an image for the button. I use custom actions mainly for attaching a button to a list item to manually start a workflow. For example, say you have a document library. A workflow is associated with this library that moves a selected document to another library and sends an email to the manager. This workflow is to be started manually. How about a nice button in the ribbon and in the item menu that says 'Move to Approved Library'? It can be simply done with SharePoint Designer.

Reusable workflows were much anticipated and are a great improvement - they can be defined once and attached to many lists and content types across the site collection. In the previous paragraph I mentioned one important use of custom actions - attaching workflow buttons to lists. The problem is, you can't do it as easily with reusable workflows that target a specific content type. There is a solution, of course.

With list workflows you can select the workflow from this dropdown when creating the custom action:
workflow dropdown
However, you can't see any content type specific reusable workflows in this dropdown (which makes sense - say you have multiple content types in a list, you'll see the same button for all items even if they're not of the content type related to the workflow. Make sure your list contains only items that the workflow can run on.)

The solution is to choose the Navigate to URL option and enter the URL of the workflow initiation page. You need to make this URL as parametrised as possible so it can be ported to other environments without the need to change IDs. Here's how:
  1. Open the initiation workflow page - simply start a new workflow on an item. Copy the address from the address bar, you'll get something like this:
  2. Replace the site address (everything before /_layouts) with this token: ~site
  3. Replace the list ID (List parameter, including the curly braces) with this token: {ListId}
  4. Replace the item ID (ID parameter) with one of these tokens: {ItemId} or {SelectedItemId}, depending upon the custom action. All the actions require {ItemId} except View Ribbon which requires {SelectedItemId}.
  5. Leave TemplateID - it is unique to the site collection, in another deployment you'll have to change it accordingly.
  6. Remove Source - it indicates the page to return to after starting the workflow, the default is the list's default view.
You are left with the final URL:
Now you can enter it in the Navigate to URL box and continue defining the custom action as you like.

* no official Microsoft documentation!

Print Friendly and PDF


wickid1ne said...

I was able to associate my RW with the Custom Action Button, Thanks. Now how can i get my custom action button to work in a site template so that i do not have to add the custom action button to every site that will need it?

zebratale said...

Great info, thank you.

Will said...

Thank you very much for this concise and super-helpful walkthrough.

Post a Comment