**all the images from this document are from our internal test environments, any resemblance with real environments are mere coincidence.**
You want to configure a business rule to get the count of dependents for one specific employee which will be used in a validation.
By doing a research in out Business Rules Implementation Guide you were able to find the function called "Get Count Of Dependents()" but this function does not seems to work.
SAP SuccessFactors Employee Central (EC) - All Versions
To use this function you must add 4 parameters being 3 option and one mandatory (relationship type).
Below you can see the list of parameters and which value they expect:
- Person ID External: This is the ID of the user whom the dependents are related which means the ID of the Employee;
- User ID : In some cases the user ID might be different from person ID External so here you need to inform the userID of the employee whom the dependents are related;
- As On Date: Here you need to inform the effective date you want the function to check if there is dependents active;
- Relationship Type: here you add the relation ship type be there is an important note here. You must add the External Code for the relationship type according to your picklist "personRelationshipType";
Here you have an example how this rule can be configured:
This function will only retrieves the count of the dependents which are already saved in the database so the dependent you are saving will not be considered see the detailed explanation below:
- The dependents session of the employee is empty;
- You start adding a new dependent and save it;
- This business rule is configured as onSave in the dependent portlet so it will be triggered and the result for this function will be 0 because at this moment no dependents exists in the database yet;
- You come back to the employee and add a second dependent with the same type;
- When you save, the rule is executed again and this time the result will be 1 because you have the dependent added in the steps 2-3;
You want to create a business rule which will validate if the employee is adding a second dependent with the type spouse, if this happens then it should trigger an error message.
Before explaining this scenario is important to explain that it will not be supported to have an onSave rule for this purpose because it triggers individually for each record of dependents added so you need to create a warning message and add this as an onChange rule in the field relationship-type.
Note that in the example above the relationship type instead of having a fixed value, has a dynamic value retrieving the external code from the current value of the dependent so you have this option as well.
KBA , LOD-SF-EC-RUL , DO NOT USE - Business Rules & Event Derivation , How To