Configuring First Half or Second Half Leave Request Scenario
Requesting leaves using mobile is one of the most used Employee Self Service scenario next to recording Timesheets.
It is quite common that an Employee needs to request half day leaves either in the first half of the day or in the second half of the day. Often it gets difficult to track or report these half day leaves for a duration-based user because there is no start and end times entered while requesting leave for a duration-based user as they only need to enter the duration of leave. Hence, it is required that Employee enters additional information about the leave i.e. whether the leave was taken in the first half or the second half.
In this blog post you will learn how to configure requesting of leaves in first half of the day or during second half of the day for a duration-based user.
I want to highlight that this half day leave request solution with conditional custom field also works with Mobile Time Off.
This solution makes use of a custom conditional field with a predefined name and a take rule.
The custom conditional field is used so that the field only appears on the UI when employee is requesting a half day leave.
The Take Rule is used to validate that the system doesn’t accept first half or second half leave two times. If Employee already requested leave during the first half, then he(she) should not be allowed to request a leave again in the first half.
Additionally, if you want to report on exact hours of first half leave or second half leave, you can create 2 more custom conditional fields of types start time and end time. Please note that these 2 custom fields will not be visible on mobile because of current limitation with general custom conditional fields.
Step 1: Create a Picklist
Go to Picklist Center and create a picklist with values “First Half” and “Second Half”.
Step 2: Create a custom field in Employee Time object definition
Go to Configure Object Definitions->Object Definition->Employee Time and create a new custom field with name as “cust_AmPmForFractionLeave”. If you use this name, then this custom conditional field would also appear on Mobile device.
Make sure that you set the field property Required = “Yes”. This will ensure that the field is mandatory while creating a leave.
Step 3: Define a condition on this custom field with FractionQuantity
Click on the details of the custom field and maintain the condition based on the Field Id as fractionQuantity. If your Time Type configuration is in days and Permitted Fractions For Unit Day = “Half day bookings allowed”, then use 0.5 in the condition value.
If your Time Type configuration is in hours and you have used “Full hours booking allowed”, then you can select the number of hours in the condition value depending on what hours constitutes half day as per your work schedule(E.g. 4 hours for a half day leave for a 8 hour/day work schedule day model).
In my example, I have used the Time Type with unit “Days”, hence the fractionQuantity selected is 0.5
Here is how you can define additional custom conditional start time and end time fields which can be used for reporting exact hours. You need to define the same condition on fractionQuantity for these custom fields as well. You can include it as per your needs. In my test scenario, I have not included these custom fields.
Step 4: Configure the Take Rule on Time type
The take rule is used to validate that the leave is not requested twice in the first half of the day for example.
First, you need to use 2 variables to get the existing leave with first half and second half using a lookup. In the lookup, you need to take care that you are not retrieving the cancelled and declined entries.
Second, add the if conditions to check if the requested leave is already in the database. If already present, then raise an error.
It is important to include the processing action of the take rule so that the validation is triggered for both create and edit scenarios. In the edit case, if both values are in the database, then do not allow editing. In this case, employee needs to cancel the leave and create a new one.
Alternatively, if you want you can raise specific error message on each “or” condition. For example, you can raise a separate message if user has already requested for first half and trying to request again. Similarly, you can raise a separate error message for the edit case.
Now, let’s take a look how it works!
Let’s say Employee is requesting leave on first half of the day for 23rd Feb,2021.
The custom field will be displayed as a mandatory field on the UI if the Requesting quantity is selected as 0.5 days as shown below.
Employee requests the leave for the first half and submits the leave.
Now, Employee is trying to create the leave request on the same date(23rd Feb,2021) for first half again.
Error is thrown as expected and the employee is not allowed submit this leave.
In order to keep the brevity of the blog post, I have not added the screenshots of the edit case but it works with the above take rule.
In this blog post, you have learnt how to configure the solution for requesting leaves on first half or second half of the day using a custom conditional field and a take rule. This solution works for both web as well as mobile devices. The solution can be adapted depending on your business needs.
Looking forward to your comments and feedback.