The Leave Management LWC App is a personal project and demo application for learning purposes. It's a basic yet functional tool for handling leave requests, tailored to demonstrate the essentials of a leave management system within an organization. The app, designed with user-friendliness in mind, serves to illustrate how employees and managers can interact with leave balances and requests. Structured as a Salesforce Lightning Web Component (LWC), this application offers a practical example of LWC capabilities in implementing core features of a leave management system.
The app is built on a Lightning App Page and includes the following components:
- Leave Balances: Displays the current user's leave balance.
- Leave Requests: Divided into two sub-components:
- My Requests: Shows the leave requests of the current user.
- My Team's Requests: Displays the leave requests of the current user's team members.
Notes: Credit to Leave Tracker App which is used as a base for my Leave Requests component.
The app incorporates the following objects to manage its data:
- Leave Requests: This object has a lookup relationship to the User object via the
Employee
lookup field. - User: The User object contains a lookup to a manager User through the
Manager
lookup field. - Leave Entitlements: Implemented as a hierarchical custom setting, this object defines the leave entitlements for each user.
- When a user submits a leave request, its status is set to
Pending
. This request becomes visible to the user's manager, who can then approve or reject it. - Upon approval, the user's leave balances are updated accordingly. The leave balance calculation is dynamic and occurs when the Leave Management App page is loaded.
- Access to the Leave Request object and its fields is managed through the
Leave_Request_permission_set
:- Object permissions: Read, Create, Edit, Delete.
- Field permissions: Read and Edit All Fields.
- The Org-Wide Default (OWD) setting for the Leave Request object is set to
Private
. - A role hierarchy should be established to allow managers access to their team members' leave requests.
- Clone the repository to your local machine.
- Use Salesforce CLI to authorize your Salesforce org where you intend to deploy the app.
$ sfdx org:login:web --alias <org-alias> --instance-url <org-url> --set-default
- Navigate to the root directory of the project in your terminal.
- Deploy the components to your Salesforce org
$ sf project deploy start -x manifest/package.xml
- Enter data for the
Leave Entitlements
custom setting
- Assign the
Leave_Request_permission_set
to all Employee and Manager users in your org. This permission set is crucial for accessing and managing leave requests. - Ensure that the
Leave Requests
tab is visible to the necessary users. For admin users, this might require granting additional view permissions.
- Ensure that each employee's user record is linked to their respective manager using the standard Manager lookup field on the User object.
- Set up a role hierarchy in your Salesforce org to reflect your organization's structure.
- This hierarchy is essential for managers to access and manage their team members' leave requests.
- This application is a demo and implements only the most basic flow of a leave management system.
- It does not include validations such as checking if the user has sufficient leave balances.
- In this demo version, all users are assigned the same leave entitlements.