SharePoint 2007: Authoring custom workflows using SharePoint Designer

Posted on 8/29/2006 @ 1:28 PM in #SharePoint by | Feedback | 17301 views

Sorry for the long break in my blogging. I’ve been a bit tied up to say the least. I got back from Redmond last week, and I took this picture with my phone as the plane rose above the clouds and I saw Mount Ranier for the first time on this trip. Behind that you can also see Mt. St. Helens. Gotta say, it was a lot better in person. One thing I don’t like about visiting the Seattle area is the terrible GPS reception there.  Can anyone explain that? Besides that, I always love visiting the Microsoft campus – damn it must be fun working there.

So, besides that.

Let us talk about authoring custom workflows in SharePoint 2007 using SharePoint designer. The best way to explain anything is to cook up a real world problem and then implement it. So let us say, I wish to create a document library where all meeting minutes are stored. Soon as a new meeting minute is dropped in the document library, I'd like to allow the user to send out an email to a select group of individuals. This could be easily achieved using a number of ways.

a)You can subscribe the relevant folks to alerts – but the email text is not configurable.

b)You can tap into the ItemAdded or ItemChanged event and send an email – but that will require you to write some code.

c)Or, you can author a custom workflow, which can perform the activity of sending out an email.

Of these three, I like #c the most because it requires the least code, and offers the most extensibility. In fact, what if I wanted to allow the end user to be able to specify a custom message on top of the email being sent out? This is something that you would have a hard time achieving through #b, pretty much impossible using #a, but darned easy to do using #c.

So let us solve this problem using #c – authoring a custom workflow.

To begin, let us set up a document library that will hold my meeting minutes. I will then attach a workflow to this document library. As usual, go to Site Actions -> Create

Click on “Document Library” under “Libraries”

Fill out the necessary details –

And click “Create” as shown above to create your document library.

Next, fire up SharePoint designer, and use File -> Open Site to open the site that contains the above document library inside SharePoint designer. You should see the site structure opened in SharePoint designer as shown below.

Next, in SharePoint designer, create a new workflow as shown below:

Fill in the necessary details as shown below:

Now, in my workflow, I wanted to allow the end user to be able to specify his custom message on top of the email that was being sent out. In order to do so, I will click on the “Initiation” button, and specify a field called “CustomMessage” as shown below:

I will then click on “Next” and specify custom conditions and actions as shown below.

When I click the “this message” hyperlink above, I can specify the details of the message as shown below.

As you can see, I have also extracted stuff out of the metadata about the list and the item to create a more meaningful message. This extraction can be done using a dialogbox as shown below.

Go ahead and finish the workflow. You would note that a workflow has been added to your site as shown below.

Let us now go back to the browser, and go ahead and upload a document in this document library. This can be seen as below:

Click “OK”

Now in the uploaded document, let us start the workflow. Go ahead and click on “Workflows” as shown below.

Click on “Email WF”

Specify your custom message –

 And bingo – check your inbox – you should see an email. w00T!! J. Oh, and need I mention, you can make this workflow much more complex to reflect your business processes. Heck you can even supplant it with custom activities.

Now there is an interesting gotcha here though. What if the workflow was set to start automatically? GO ahead – try it out.

You would note that in such a situation, you cannot pop up the initiation aspx. Hmm. There are two workarounds to that problem.

a)Request initiation data when the file is being uploaded – basically as custom fields on the document library or list.

b)Using Visual Studio create a workflow and create input forms using Infopath. The automatic workflow requires user input using those forms. I hope to blog about that soon (wish I had more time).

Hope you found the above helpful. Adios.

Thou shalt -

Sound off but keep it civil:

Older comments..


On 9/17/2006 4:37:07 AM amit said ..
hi,


i have a querry regarding sharepoint 2007. How can we inherit the theme of the sharepoint in our controls of the usercontrol that we host in the sharepoint. Please help me this is really urgent.


On 1/5/2007 4:42:52 AM Mili said ..
Can we customize a approve/reject type of workflow with Sharepoint designer. I want to have a conditional workflow wherein the appropriate person is allowed to approve/reject the document uploaded.


On 1/5/2007 11:44:47 PM Sahil Malik said ..
Mili - you can certainly author new workflows using existing and new activities.


On 7/5/2007 12:22:45 PM J Moreno said ..
It looks like your example/instructional images have been deleted...they aren't showing in either IE or Firefox, and FF says they are all 0kb.


On 7/5/2007 10:23:14 PM Sahil Malik said ..
Seems to work 4 me ! :-/


On 8/6/2007 7:39:33 AM Pedro said ..
Hi Sahil


I'm having a problem with the woorkflow lookup. When I call for a hyperlink the address doesn't come complete. For example:


What I should have to hyperlink directly to some particulat page is: http://intranet2/Lists/Anuncios/DispForm.aspx?ID=32&Source=http%3A%2F%2Fintranet2%2FLists%2FAnuncios%2FAllItems%2Easpx


What I do have at the e-mail I receivec is: http://intranet2/Lists/Anuncios/32_.000


Also, is there anyway to customize the fonts used on the e-mail sent by Sharepoint?


On 8/7/2007 1:25:28 PM Pedro said ..
Hi again

I've found the answer to my question here: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1548263&SiteID=1

Thanks


On 1/23/2008 2:30:01 PM Brenda said ..
I cannot see the pictures either - do you a document of these instructions which you can email? I appreciate your response.


On 2/22/2008 7:30:59 AM Anil said ..
Originator creates a document that is sent to three checkers ( can be 1,2 or many). When one of the checker reviews (and approves) the document the document should go to the both the approvers. If one of the approvers approves the document the workflow is complete. On the other hand, if one of the checker or approver rejects the document it goes back to the Originator.

The requirement is : Sent the document to many individuals for approval. But only one approval is required to go to the next step


On 7/2/2008 1:26:29 PM Ted said ..
RE: Emails with a hyperlink

Lets say you send the email as described above and you want to include a hyperlink for the user to go to after receiving the email.

Simply add html in the form of an "a_href_=_http://_website name_<_/_a>"

*note: remove all underscores from the above html and you will be able to embed a hyperlink int your email using the Sharepoint designer workflow interface.


On 7/14/2008 10:45:22 AM femi said ..
thanks for this but i have a question,


how does the user get to enter his custom message if the workflow is set to fire automatically when a document is uploaded?


Does he get a prompt WHEN uploaded the doc?


Thanks


On 10/26/2009 4:06:57 PM Bryan said ..
I have created the same work except for the Initiation button and it all works fine. However, when I save the site as a template and create other sites from it the workflow sends emails without any metadata. Any ideas as to why this would be?


On 6/8/2010 1:10:19 PM Rob said ..
Could you please repost the image.


On 6/15/2010 9:36:38 AM Sree said ..
Hi i Have a requirement like if a user requestor submit some request then work flow has to start but only that user has to see. Is there is anything like that we can do?