Working on Time-Off, we often get requirement which is effective only with certain dependency.
And it makes sense to have data updated only in dependent portlet which could be validated and needful could be done.
To explain, i am taking example of parental leave, which is applicable only after child birth.
Below are the criteria considered in this scenario-
- Parental leave is eligible only till new born is 6 months old.
- Maximum 5 days can be availed per child.
To achieve above stated, these Take Rules are created-
- To check if new born´s data has been updated-
The rule determines the following-
Using `Get Count of Dependents ()` to check if dependents portlets has been updated with data. As Relationship Type is ´2´, which is external code for ´Child´ in Picklist – personRelationshipType. If no child data is maintained, an error would pop up.
2. To check if child´s age is not more than 6 months
The rule determines the following-
´Get Age of Dependents in Months()´ gets the age of the dependent for a given list of relationship types and ranked as of a given date.
Rank-1 is for the latest data of particular relationship type.
Relationship Type – 2 is external code for Child.
if the age of latest child data, in dependents portlet, is more than 6 months, an error will pop up.
3. To check if not more than 5 days are availed within 6 months of new born birth-
This rule determines the following-
Significance of ´Get Age of Dependents in Months ()´ is already discussed above.
using this function again to keep ´6 months validity´ criteria and adding an AND operator to calculate the total leaves taken-
Get Absence in Days for Period () will fetch leaves already availed from-
Start Date- Youngest Child´s Date of Birth as maintained in Dependents portlet (via function Get Date of Birth of Youngest Dependent ())
End date – the present date when leave is being availed again.
´Adding´ the above output with –
Get Number of Calendar Days (), which will fetch number of days between start date and end date, that is, leave days being availed in present.
if the output is more than 5 days, system will pop up an error.
Also, be mindful of Time Type external code. Only one time type can be maintained. If multiple time types have same requirement, multiple rules should be created (just copy the rule!).
Finally, the above rules to be placed under Take Rule of time type (Parental Leave in our scenario).
Please Note-
- This solution can be achieved only if Dependents portlet is being used.
- The rule will capture only youngest child´s data and hence overlapping will not be captured.
Hope this is helpful.