Creating A Simple SharePoint Workflow In SharePoint Designer

This one is a quick and easy one, but is the basis for creating some very useful workflows in for use in SharePoint lists. Firstly you will need a SharePoint website and a copy of SharePoint Designer (a 60 day trial version is available from microsoft) and a list in SharePoint which you can apply the workflow to – for this example I am using a fairly simple Travel Requisition list which is a document library which contains InfoPath documents.

To create the workflow open SharePoint designer and connect to your SharePoint website. Once connected, go to File -> New and select the SharePoint Content tab and select Workflow (blank workflow). You should now be presented with the a form similar to the following. Here you can specify a name for your workflow (each workflow in a site must have a unique name) which list the workflow is attached (associated) to and when the workflow should be triggered. In this case we want to trigger the workflow whenever a list item is added or updated.

The next step is to define the actual steps of the workflow. Although it’s not necessary, the first step that I like to perform is to log a message indicated that the workflow has been initialised and is being performed. Additionally I like to also log a message when each step is starting and when each step has been completed. This logging can be achieved simply by using the action “Log message to the workflow history list”.

For this workflow what we want to do now is send an email to the travel requisition assignee, notifying them of a new request which requires their approval. As the workflow is being triggered when a new item is added, or when an item is modified (to capture updates later) we will need to safeguard against the fact that the assignee might have already been sent a notification email (this could also be done using a specific column with a boolean value and updating this column in the workflow). To do this we need to create a workflow status column in our sharepoint list and put a condition around our next workflow step.

To create the required column; In SharePoint create a new column of type “Choice”, on the associated list, and add several workflow statuses. For example, Pending Approval, Approved, Declined, Completed.  Now back in SharePoint Designer, in our workflow wizard, click Add workflow step and in the conditions select Compare [list name] field then set the first field to the Workflow Status column we just created and the equals field to the first value (in this case Pending Approval). This will restrict this step from only being processed if the document is pending approval, i.e. when the form is first submitted.

A step would be pretty useless if it did not contain any actions, so go ahead and create an action to log the task we are about to perform (or don’t :-). The next action we want to perform is to send an email to the approver, to notify them of the new requisition. The action we want is called send an email – select this and then click this message, to specify the message contents.

In the Define E-mail Message screen click the address book button next to the To field. You can now specify who should receive the email address – this can be anyone from Active Directory, a custom email address, a SharePoint user, or in our case a workflow lookup value. To specify a workflow lookup value double click on Workflow Lookup… in the list on the left. The source should be left as Current Item and the field value should be set to the field containing the email address of the person who is going to approve the form.

After clicking OK twice you should be back at the Define E-mail Message screen, where you can now specify the subject and body. If you wish to make the email a little more personalized you add lookup’s to the body by clicking the Add Lookup to Body button and selecting a field using the same method as when we select the email address. One useful field to add to the body is the Encoded Absolute URL field. This field outputs the complete URL of the form to allow the approver to click this link and directly open the form for completion – instead of having to browse to the site and then search through the list for the new form.

Now we are done! This is a very simple workflow, however it can easily be extended to allow additional tasks to be automated. For example, the next step may be to email the appropriate person based on the actions of the approver – if they approve the requisition it might then notify a line manager of this approval; if they decline the requisition it might notify the person it has been declines; or the approver may not be responsible for this approval and as such delegate the task to someone who is responsible. The following image show such example.

Where to next? Complex workflows in Visual Studio, with code behind functionality…

(note original post had images but were lost in blog transfer)