In this article we can explore the Leave Approval Scenario without using Workflows.
In this article we can explore the Leave Approval Scenario without using Workflows.ScenarioThe following are the users of the system:
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?SolutionWe can have 2 approaches for a solution here:
For simplicity's sake we are using the List Content Approval feature. The Workflow based solution can be used for more complicated scenarios.The following are the steps involved in List Content Approval solution. Create New UsersCreate 3 new users for our purposes. If you are using the Windows 7 operating system then go to Control Panel > Users Accounts item.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.Create New Site CollectionAfter 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 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 PermissionsAfter 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 2 users (employee1, employee2) into this group using the New > Add Users menu item. After adding the 2 users the list should look like:Now these users should be able to view the lists and libraries inside the site collection.Create New ListNow perform the following:
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:
Enable Content ApprovalThis 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:
To enable this feature open the preceding 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 will see that a new column is added to the List view.Note: it can be done using the Server Object Model list property EnableModeration.Modify Default ViewWe 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:
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:Scroll down to the Filter section and set the following:The filter shows the item only on the following true condition:
Sign in as Employee 1Now 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 new browser instance that appears 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 will see that the Approval Status is automatically set to Pending.Sign in as Employee 2Now 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. Now create a new leave item inside the Leaves list. Set the leave time as Reason for Employee 2 as shown below.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 ManagerNow you can go back to the manager browsing session. You should be able to ____ 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 it for the second item too. Back to EmployeesBack 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.Referenceshttp://tinyurl.com/sp2010-contappr SummaryIn this article we have explored the Content Approval feature using a Leave Approval scenario. The following are the points worth remembering:
To try with the email notification, you need to configure email settings for SharePoint.
Getting Started with Managed Metadata Service in SharePoint 2010