Introduction
In this article we can explore the Leave Approval scenario without using Workflows.
Scenario
Following are the users of the system.
- manager (The Manager)
- employee1 (An Employee)
- 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 can we attain the functionality?
Solution
We can have two approaches for a solution here:
- Use List Content Approval
- Use Approval Workflow
For simplicity sake, we are using the List Content Approval feature. The Workflow based solution can be used for more complicated scenarios.
Following are the steps involved in the List Content Approval solution.
Create New Users
Create three new users for our purpose. If you are using the Windows 7 Operating
System, go to Control Panel > Users Accounts item.
If you are using the Windows Server Operating System, use the Active Directory section of the Server Manager application to add the new users.
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.
Note: Adding as Primary Site Collection Administrator adds the manager user into the Site Owners group in Site Permissions. Owners should have permissions to change the settings for lists, view, etc.
Assign Site Permissions
After creating the site collection open the new site using the URL. Sign in as the user manager.
Go to Site Actions > Site Permissions and open the Members group.
Add the other two users (employee1, employee2) into this group using the New > Add Users menu item. After adding the
two users the list should look like:
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
You can see that the Created By, Modified By columns are automatically added and represents our employee who applied for the leave.
Following is the default View of the List.
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 above list in manager mode and go to the List Settings.
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.
Now you can see that a new column is added to the List view.
Note: The same can be achieved 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 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 achieve this, open the Leaves list and go to List tab and click on the Modify View button as shown below:
Scroll down to the Filter section and set the following:
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.
In the appearing new browser instance, sign in as Employee 1.
Now create a new leave item inside the Leaves list. Set the leave time as Reason for Employee 1 as shown below.
You can 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 appearing new browser instance, sign in as Employee 2.
Now create a new leave item inside the Leaves list. Set the leave time as Reason for Employee 2 as shown below.
You can see that the Approval Status is automatically set to Pending.
Note: You can see that Employee 1 is only able to see his own leave item and
the same is the case 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
see both the list items.
As a manager you can Approve or Reject the item by selecting the list item and using the tool bar button.
On clicking the Approve/Reject button, you will get the following dialog.
You can repeat the same for the second item too.
Back to Employees
Back to the Employee 1 session, you can see the corresponding leave item as Approved.
Now back in the Manager screen, reject the remaining leave item and login as Employee 2 to see the status as Rejected.
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.
References
Summary
In this article we have explored the Content Approval feature using a Leave Approval scenario. Following are the points worth remembering:
- Content Approval allows item approval without using Workflows
- 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.