- Custom Actions (create ribbon buttons and item menu actions)*
- Reusable Workflows (create a workflow once and use it across the site collection)
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:

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:
- 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:
http://sitecollection/subsite/_layouts/IniWrkflIP.aspx?List={a2f7d901-97eb-4a54-b10f-46fb1714084e}&ID=6&TemplateID={45f06fec-61f9-4dd4-ba70-70321c29615d}&Source=http://sitecollection/site/Lists/Tasks/AllItems.aspx
- Replace the site address (everything before /_layouts) with this token: ~site
- Replace the list ID (List parameter, including the curly braces) with this token: {ListId}
- 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}.
- Leave TemplateID - it is unique to the site collection, in another deployment you'll have to change it accordingly.
- Remove Source - it indicates the page to return to after starting the workflow, the default is the list's default view.
~site/_layouts/IniWrkflIP.aspx?List={ListId}&ID={ItemId}&TemplateID={45f06fec-61f9-4dd4-ba70-70321c29615d}Now you can enter it in the Navigate to URL box and continue defining the custom action as you like.
* no official Microsoft documentation!
3 comments:
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?
Great info, thank you.
Thank you very much for this concise and super-helpful walkthrough.
Post a Comment