Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / productivity / SharePoint / SharePoint2010

Step by Step Guide in Developing Your Own Workflow in Sharepoint 2010

4.00/5 (9 votes)
7 Nov 2010CPOL4 min read 127.2K  
Here is a step by step guide in developing your own workflow in SharePoint 2010

Workflows are a real poweful tool built-in in Sharepoint since 2007 version as you can design it to add logic to your site or application without any custom coding! This can be anything from automating business processes, sending notifications or even as simple as creating tasks. There are a lot of possibilities which are only limited by your imagination.

This article will discuss how easy it is to develop your own workflow in Sharepoint 2010, you don't even have to be a developer as you will not write any custom codes and all you have to do is just a series of mouse point and clicks. To get started, we need an entry point in the workflow, this will act as a trigger to start the process and one good example that we can use is when someone adds an item to a list. So in this sample solution, we will be developing a workflow to trigger from a list and based on the selection on one of the list column values, it will trigger an email to be sent and update the items status. Using this example, I guess we will be tackling most of the important aspects of workflows such as steps, conditions and actions.

So let's start!

Let's start by creating a list and here is the structure.

Image 1

Now for a bit of explanation, here is what each field does:

  • Title - That will be the subject of the email you will be sending
  • User Email - The recipient email address
  • Message To user – The message in the email
  • Status - What's the status of this item (choice between Started, Email Sent, Processing, Resolved)
  • Send Email - A flag whether email will be sent to recipient.

Once you created the list, fire up Sharepoint Designer and start creating your workflow. First, go to List and Libraries:

Image 2

Choose your list and go to the Workflow section, then create new:

Image 3

It will ask you to define a Workflow name and description:

Image 4

Now, the workflow designer shows:

Image 5.

Now if you notice on the ribbon, there is a Condition and Action Button, there are the key elements for designing the workflow, examine the items inside and these as it will list all the possibilities you can do.

Workflow Action Items

Image 6

Workflow Condition Items

Image 7

On your Step 1, we choose “Email users” (this means when the workflow starts, it will email a certain user of your choice).

Image 8

Now define the Email Message:

Image 9

On the “To” section, choose users. At this point, we choose the email address stored on the list item.

Image 10

We select that “User Email” column you created on your list.

Image 11

Now on the CC, you will add the one who added the list item.

Image 12

For the title, we will get it from the “Title” column in your list:

Image 13

And for the body, you choose the “Message to user” column in your list as well as the “Modified by” field:

Image 14

Congratulations! You are done with your first action, now let's add a condition on that action.

Click on the top of the first action you had created:

Image 15

Add a common condition “If any value equals value” which means if a certain column in that current item falls in a value that you declare, an action will be triggered:

Image 16

Now the condition appears on top of your first action:

Image 17

Now modify the values to what you want, since you want an action to happen when “Send Email” field has a value of “Yes”, then define as such.

Image 18

Image 19

If you had noticed the First action you created was not on the IF block, so you need to move it up, to do that, choose the drop down on the side and choose move action up.

Image 20

This will then place it inside the IF block:

Image 21

Now in this scenario, let's say you also want to update the field “Status” to “Email Sent” when the email sent. To do that, add another action by choosing the “Set Field in Current Item”. Make sure that you also click below your first action so that when you add a new action, it will be placed there.

Image 22

Now set the field and value properties:

Image 23

Now for your ELSE block, choose the “Else-If Branch” from the ribbon:

Image 24

Now do the same action above but this time set the “Status” to “Processing”:

Image 25

Now you are all done! Save and publish your workflow:

Image 26

Then, wait while it's validating:

Image 27

But wait, you need a trigger on when the workflow will start. Do that by going to the Workflow objects, choose your workflow and configure it on the start options:

Image 28

Now all you have to do is test, create a list item to trigger conditions you built:

Image 29

Then wait for the results:

Image 30

Image 31

That's it! It's that easy, no coding required!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)