Hello Guys,
I was thinking to write a blog post which explains to publish a dynamic content in the error message by using business rule engine. Now, this is the time. I think, this will be of huge value addition to the customers.
Scenario:
This blog explains about publishing a dynamic value of “Overtime” in the timesheet if XYZ Organization is using “Overtime” as a type of allowance and this allowance needs to be manually recorded in the timesheet by the employee.
Use Case:
Timesheet referred here is of Time Recording Variant type “Duration”. I Chose Duration to create a profile for employees who record only the duration of their work within a specific period, in hours and minutes.
Scheduled working hours assigned to an employee for a particular day is 8 Hours 30 Min. Number of hours is being derived here from the Work Schedule of “Simple” model.
On a working day, an employee works for 9 hours 03 min and tries to record an Overtime of 1 Hour. System hereby should restrict this transaction with a dynamic value as the policy of this XYZ Organization says, to record overtime, minimum number of clocked duration should be 1 hour more than that of total number of scheduled hours.
Configuration:
Message Definition:
Message definition is configured with 3 different parameters highlighted as under.
IF Condition:
In this scenario, business rule is used in the validation rule in Time Recording Profile.
IF condition here calculates the number of scheduled working hours for a user using the function “Get Number Of Working Days Or Hours For Period()”. This derived hour, is now compared to the clocked hours/duration.
THEN Condition:
A dynamic value of (scheduled Hour + 1 Hour) is then published in the error message using multiple functions.
Phased Calculation for the parameter “hours”:
Get Number Of Working Days Or Hours For Period()
This function returns total number of scheduled hours for the day of recording Overtime allowance. This function derives the scheduled hours from work schedule assigned to the user. In this case, this function returns 8.5 Hours.
Multiply()
In this case, this function converts hours into minutes by multiplying by 60. Value returned here is 8.5*60 = 510 Minutes.
Add()
In this case, this function now returns 510 + 60 = 570 Minutes.
Divide()
Result (570 Minutes) is now converted into Hours by dividing by 60. In this case, value returned is 9. Minutes value will now be calculated in the next section.
Phased Calculation for the parameter “minutes”:
Get Number Of Working Days Or Hours For Period()
This function returns total number of scheduled hours for the day of recording Overtime allowance. This function derives the scheduled hours from work schedule assigned to the user. In this case, this function returns 8.5 Hours.
Multiply()
In this case, this function converts hours into minutes by multiplying by 60. Value returned here is 8.5*60 = 510 Minutes.
Add()
In this case, this function now returns 510 + 60 = 570 Minutes.
Modulo()
Result (570 Minutes) is now converted into Minutes by using the function Modulo() with divisor 60. In this case, value returned is 30.
Final Result:
System restricts user from recording 1 hour of overtime as recorded hours (Imported Time) should be more than or equal to scheduled working hours + 1. In this scenario, recorded hours (Imported Time) should be more than or equal to 9 Hours 30 Min.
Error Message:
Conclusion:
We were able to publish a dynamic content in the form of error message successfully while recording “Overtime” allowance in the time sheet application.
If you find this blog post helpful, I would encourage you guys to comment and share this blog post. I also invite my readers to offer their views and opinions. I make sure they are heard and valued ?
Have a wonderful Implementation!
Thank You.