ow to loop through a collection of objects in the openl tablets and pass this identified object to the next set of rules.
For example : I have a root object and the root object has an attribute which is a collection.
Root object => Employee
Child Attribute Collection => Departments in which Employee has worked
Department => Is a specific Data type which has attributes like, name, location, from and to date
What I would like to do is to have a parent rule that takes the Employee as an input parameter.
Check if the employee has worked in a specific department like for example finance
Pass this specific department to subsequent rules.
Example code:
boolean rule1 = false;
boolean rule2 = false;
For ( Each Department of the Employee){
if(department.name === finance){
rule 1 = //execute rule 1(Department);
rule2 = //execute rule 2 (Department);
break;
}
}
The output should have the values of rule 1 & rule 2 if the Employee has worked in the finance department.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
The example from the attachment illustrate the best practice when user needs to execute the rule for each array element. In such case pass the array as parameter into the rule designed to accept a single value.
In the example attached the rule "DepartmentRules" that is called in the CalculateEmployee spreadsheet will be executed for the each Employee department, because the rule expected a single department as input parameter, but called with an array of departments.
ow to loop through a collection of objects in the openl tablets and pass this identified object to the next set of rules.
For example : I have a root object and the root object has an attribute which is a collection.
Root object => Employee
Child Attribute Collection => Departments in which Employee has worked
Department => Is a specific Data type which has attributes like, name, location, from and to date
What I would like to do is to have a parent rule that takes the Employee as an input parameter.
Check if the employee has worked in a specific department like for example finance
Pass this specific department to subsequent rules.
Example code:
boolean rule1 = false;
boolean rule2 = false;
For ( Each Department of the Employee){
if(department.name === finance){
rule 1 = //execute rule 1(Department);
rule2 = //execute rule 2 (Department);
break;
}
}
The output should have the values of rule 1 & rule 2 if the Employee has worked in the finance department.
Hello,
The example from the attachment illustrate the best practice when user needs to execute the rule for each array element. In such case pass the array as parameter into the rule designed to accept a single value.
In the example attached the rule "DepartmentRules" that is called in the CalculateEmployee spreadsheet will be executed for the each Employee department, because the rule expected a single department as input parameter, but called with an array of departments.
Best Regards,
Alena.