Geeks With Blogs

News





The SharePoint Hillbilly Fewer Big Words... More Pretty Pictures...

Show of hands, how many people are tired of explaining to users what a SharePoint Workflow is and how to navigate to the workflows???

“Okay, click on the little down arrow, you should get a menu, now click on ‘Workflows’” or “Go to the item display and click on the menu option ‘Workflows’”.

“Now, you see a list of all the workflows… yes… I know the buttons are ugly… yes ma’am/sir, I’ll look into changing that. Okay.. now back to the ugly buttons… no.. ignore that section labeled ‘Running Workflows’. You don’t need to worry about that.. yes ma’am/sir, you can ignore that ‘Completed Workflows’ section.. we are just concerned with the section labeled ‘Start a New Workflow’.  Yes, I agree it’s confusing.  Yes, I know… Yes ma’am/sir I’ll look into that right away…“

How many times have you uttered the words “Sorry, that’s SharePoint”?

I’m sorry, but how un-user friendly is the Workflow interface in SharePoint?  Sure, if you know what you are doing it’s not too bad, but there are a ton of people out there who don’t have a clue what their doing and we get to support them.. yay! job security…

Wouldn’t it make much more sense if there were a link or a button on the display of any item that a user could click for a specific workflow?  Or wouldn’t it be great if on a list view you could execute a specific workflow directly from there?  Wouldn’t that be great? Well… in an effort to make your lives easier I thought I’d post a couple of options for you to take advantage of. I’m wondering if there is an even better way to do this? Maybe someone out there smarter than myself will let me know?

I asked the question on Twitter to find out what people were doing to solve this problem and as always got great advice quickly from Laura Rogers (@WonderLaura), Susan Lennon(@SusanLennon), and Jim Bob Howard (@jbhoward). It seems one method for doing this is to use a Workflow associated with a “Form Action” as described in detail in Natalya Voskresenskaya’s (@natalyvo) blog “Follow Up: Training Classes Scheduling Solution (Full Version)”  (start reading around step 5). I didn’t dig too deep into this solution however because it had you creating the Workflow as a custom Form Action which does not appear to allow you to select existing workflows or use initiation variables.  Custom Form Actions as Workflows looks pretty cool, but not what I’m going for here.

What I want to achieve is placing a link to an existing SPD or Custom Workflow for a list on the display form of an item.  In addition, I’d like to put the same sort of link as a column in a list so you don’t even have to go to the item display if you don’t want to.

Below is the solution I came up with.

By the way, the first thing we are going to do is parse the URL of our desired workflow. Something I’ve discovered while playing around is that if we have an SPD workflow we need to make sure and grab the List GUID and Item ID.  However, if we have a Custom Workflow we need to make sure we have both of those PLUS the Template GUID.  I have not been able to confirm if this is constant and works under all scenarios.  I’m waiting on confirmation from people smarter than myself and if I ever get a definite answer I’ll be sure to update this post.  Again for this blog I will be using a SPD Workflow.  If you have a Custom Workflow you want to also make sure and grab the template GUID.  Other important things to note, if the GUIDs change we need to make sure and update the changes we are doing here to reflect the new GUIDs in your links.  This is a good argument for NOT doing what I’m proposing.  An ideal solution would be able to automatically determine if GUIDs have changed and use those.  I don’t see that being done without custom code though. 

Last side note, I am using the site I created in my blog entry “Creating a SharePoint List Parent/Child Relationship – VIDEO REMIX”.  The only modification is that I created a manual SPD workflow on the Time List to send an email called “Send Email”.  This simple workflow has two initiation variables. “Recipient Email Address” and “Email Message” if you want to follow along exactly.

Okay… enough side notes… let’s get started

Find the URL for your Workflow

First thing thing we need to do is find the URL for the desired workflow that we want to turn into a link/button/whatever.  To do this go by whatever means necessary to the Workflows page for an item (this page:)

image

Click on the name of the workflow (In this case ‘Send Email’) to get to the Workflow Initiation Page:

image

No we need to get the URL for this page.  Just copy and paste it from your address bar.  It should look something like:

http://urltosite/Workflows/Send%20Email/Send%20Email.aspx?List=abc587ec-2ce1-4e2f-a2c8-ce6c33245293&ID=3&TemplateID={97dda5cb-6b21-4b11-b1d3-b2081fa01097}&Source=http%3A%2F%2Fmrackleyspdev%2Fblog%2Fissues%2FLists%2FTime%2FAllItems%2Easpx

Let’s break this apart real quick.  There are 5 parts to the url:

  1. Url to Workflow Initiation Page: http://urltosite/Workflows/Send%20Email/Send%20Email.aspx
  2. List GUID: List=abc587ec-2ce1-4e2f-a2c8-ce6c33245293
  3. ID for specific List Entry: ID=3
  4. Template GUID: TemplateID={97dda5cb-6b21-4b11-b1d3-b2081fa01097}
  5. Source URL: Source=http%3A%2F%2Fmrackleyspdev%2Fblog%2Fissues%2FLists%2FTime%2FAllItems%2Easpx

As mentioned earlier, it appears that all you really need to properly execute an SPD workflow are the relative URL for the Page, the List GUID, and the ID for the List Entry.  For Custom Workflows you also need the Template GUID. So the URL we end up needing is something similar to:

/Workflows/Send%20Email/Send%20Email.aspx?List=abc587ec-2ce1-4e2f-a2c8-ce6c33245293&ID=3

Does it hurt to pass the TemplateID and a Source URL as well? Nope, have at it.  However, keep in mind if that TemplateID changes then you will have to keep it in sync.

Put Link to Workflow on Item Display Page

Okay… next thing we need to do is get that URL on a page as a link and pass the correct List Entry ID to it. Best practice for modifying a DispForm is to create a custom page and re-associate the list to that page. Don’t know how to do that?  Luckily, there’s an app.. I mean video for that:

Now that we have our custom display form created we need to place a link on the page from which we will be taken to our Workflow initiation page.  We also need to get the ID for the current list entry and put it into the link.  Luckily, there is already a parameter by default that contains the entry ID called “ListItemId”. 

So, the relative URL we need to put in our link ends up being: “../Workflows/Send%20Email/Send%20Email.aspx?List=abc587ec-2ce1-4e2f-a2c8-ce6c33245293&ID={$ListItemId}

In the following video I insert an “interactive button” which is basically just a link formatted to look like a button.  You could just as easily manually enter an link in the page directly. 

 

Inserting a Link to a Workflow in a List View

Okay, now that we have a link to our workflow on the custom display form, lets put the same link into a list view.  This ends up being very similar if not a bit easier. For the following video I am using the child time list from my blog entry “Creating a SharePoint List Parent/Child Relationship – VIDEO REMIX”.  So, if you need help getting the list set up in the first place, go look at those videos. 

The main difference is that the URL for the workflow will change slightly.  We need to use the row ID from the XSLT (which is “@ID”).  Our Link for this part of the site becomes: “../../Workflows/Send%20Email/Send%20Email.aspx?List=abc587ec-2ce1-4e2f-a2c8-ce6c33245293&ID={@ID}”  (note that we had to url encode the “&” to “&” for the second parameter in this scenario. This was done automatically for us before with the dialog for “insert interactive button”).

So, what we are going to do is look through the aspx of our list view and find where it enters the value for the last column (Hours in this example) and then we need to insert a new cell into the list view with the value in the cell being a link to our workflow. This code ends up looking like:

<td class="ms-vb">
<a href="../../Workflows/Send%20Email/Send%20Email.aspx?List=abc587ec-2ce1-4e2f-a2c8-ce6c33245293&amp;ID={@ID}">Send Email</a>
</td>

So, in other words:

 

And there you have it! Again, be careful of GUIDs changing if you are moving sites around or updating workflows, but other than that this seems to work like a charm.

As always, your comments and feedback is always welcome.

Posted on Friday, December 18, 2009 5:08 PM | Back to top


Comments on this post: Outing SharePoint Workflows – Linking to Workflows in List Views and Item Displays

# re: Outing SharePoint Workflows – Linking to Workflows in List Views and Item Displays
Requesting Gravatar...
This is great and something I've been tring to do. One simple question. Can you use this to just add a link in an actual List view that initiates the workflow without having to click the link then click start for the workflow? Basically click the link and workflow automatically kicks off.
Left by Lori on Sep 02, 2011 7:05 AM

# re: Outing SharePoint Workflows – Linking to Workflows in List Views and Item Displays
Requesting Gravatar...
One additional thing to note, in my working with this, I found that including the template guid in the query string for an SPD workflow actually caused it to not work. So not only is it not needed, in my case it caused an error.
Left by FolcoTook on Feb 29, 2012 4:02 PM

Your comment:
 (will show your gravatar)


Copyright © Mark Rackley | Powered by: GeeksWithBlogs.net