Leave Approval Without Workflow In Sharepoint 2010

In this article we can explore the Leave Approval Scenario without using Workflows.

Scenario

The following are the users of the system:

  1. Manager (The Manager)
  2. Employee1 (An Employee)
  3. Employee2 (Another Employee)

An employee can apply for a leave using the list named Leaves. The Manager has the right to approve or reject a leave application. The employees should not see the applications of other employees. How to do that?

Solution

We can have 2 approaches for a solution here:

  • Use List Content Approval
  • Use Approval Workflow

For simplicity's sake we are using the List Content Approval feature. The Workflow based solution can be used for more complicated scenarios.

WorkflowBasedSolution.jpg

The following are the steps involved in List Content Approval solution. 

Create New Users

Create 3 new users for our purposes. If you are using the Windows 7 operating system then go to Control Panel > Users Accounts item.

WorkFLowNewUser.jpg

If you are using a Windows Server operating system then use the Active Directory section of the Server Manager application to add the new users.

ActiveDirectorysectionWorkflow.jpg

Create New Site Collection

After creating the users, create a new Site Collection from Central Administration. Set the Manager as the Primary Site Collection Administrator.

CreateNewSiteCollection.jpg

Note: Adding as Primary Site Collection Administrator makes the manager user into the Site Owners group in Site Permissions. The Owners should have permissions to change the settings for lists, views etc.

Assign Site Permissions


After creating the site collection, open the new site using the URL. Sign in as the user manager.

AssignSitePermissions.jpg

Go to Site Actions > Site Permissions and open the Members group.

MemberGroupWorkflow.jpg

Add the other 2 users (employee1, employee2) into this group using the New > Add Users menu item. After adding the 2 users the list should look like:

AddUsersWorkflow.jpg

Now these users should be able to view the lists and libraries inside the site collection.

Create New List

Now perform the following:

  • Open the Site Collection using URL
  • Sign in as the Manager user
  • Create a custom list named Leaves
  • Add the following columns into the List:

CreateNewListWorkflow.jpg

You can see that the Created By and Modified By columns are automatically added and represents our employee who applied for the leave.

The following is the default view of the List:

DefaultViewListWorkflow.jpg

Enable Content Approval

This is the core part of the article and we are going to enable the Content Approval feature of SharePoint 2010. On enabling this feature the List item will have:

  • A new column named Approval Status (Pending, Approved, Rejected)
  • A notification send to Manager when an item is created for Approval
  • A notification send to Employee when an item is Approved or Rejected

To enable this feature open the preceding list in manager mode and go to the List Settings.

EnableContentApproval.jpg

From there choose the Versioning settings link as highlighted above. Choose the first option Require content approval for submitted items and click the OK button.

contentapprova fo submitteditems.jpg

Now you will see that a new column is added to the List view.

ColumnAddedContentApproval.jpg

Note: it can be done using the Server Object Model list property EnableModeration.

Modify Default View

We need to do a slight modification on the view of the Leaves list. Currently the view shows the leave applications of all employees. We need to restrict it to show only:

  • The current logged in user leave applications
    Or
  • The leave applications which are pending

Note: Views provide flexibilities like applying multiple views and changing an existing leave.

To do this open the Leaves list and go to List tab and click on the Modify View button as shown below:

ModifyDefualtView.jpg

Scroll down to the Filter section and set the following:

FilterSectionWorkflow.jpg

The filter shows the item only on the following true condition:

  • Created By column equals [Me] as Logged in user
    Or
  • Approval Status column is equal to Pending

Sign in as Employee 1

Now you need to sign in as user Employee 1. For this create a new browser instance with a new session.

Note: If you are using Internet Explorer, press and release the Alt key in the keyboard to see the File menu. From the menu click the New session menu item.


SignEmployeeWorkflow.jpg

In the new browser instance that appears sign in as Employee 1.

browserinstancesignWorkflow.jpg

Now create a new leave item inside the Leaves list. Set the leave time as Reason for Employee 1 as shown below.

ReasonforEmployeeWorkflow.jpg

You will see that the Approval Status is automatically set to Pending.

Sign in as Employee 2

Now you need to sign in as user Employee 2. For this create a new browser instance with a new session. Use the same Alt + File > New Session if you are using Internet Explorer.

In the browser instance that appears sign in as Employee 2.

WorkflowSignEmployee2.jpg

Now create a new leave item inside the Leaves list. Set the leave time as Reason for Employee 2 as shown below.

WorkflowReasonEmployee2.jpg

You will see that the Approval Status is automatically set to Pending.

Note: You will see that Employee 1 is only able to see his own leave item and the same for Employee 2. The filtering of the view is doing this magic.

Back to Manager


Now you can go back to the manager browsing session. You should be able to ____ both the list items.

BackManagerWorkflow.jpg

As a manager you can Approve or Reject the item by selecting the list item and using the tool bar button.

ApproveRejectButtonWorkflow.jpg

On clicking the Approve/Reject button you will get the following dialog:

DialogApproveRejectWorkflow.jpg

You can repeat it for the second item too.

Back to Employees

Back to the Employee 1 session you can see the corresponding leave item as Approved.


BackEmployeesWorkflow.jpg

Now back in the Manager screen, reject the remaining leave item and login as Employee 2 to see the status as Rejected.

StatusEmployeeWorkflow.jpg

So this concludes our Leave Application implementation without using Workflows. For the flexibility of the Manager you can edit the site main page to include the Leaves list as shown below.


LeaveApplicationWorkflow.jpg

References

http://tinyurl.com/sp2010-contappr

Summary

In this article we have explored the Content Approval feature using a Leave Approval scenario. The following are the points worth remembering:

  • Content Approval allows item approval without using Workflows
  • The Approval Status column is automatically added to list items
  • View provides a convenient way to filter items

To try with the email notification, you need to configure email settings for SharePoint.