ChildFold
7 min
the childfold function iterates through a parent's business object's child objects, evaluating an expression in the context of each of the child objects the results of the expression evaluations are aggregated using the aggregatorfunc parameter the childpredicateexpression parameter, if specified, selects which related objects to include if not specified, they are all included syntax childfold(parentobjectref, parentrecid, childrelationshipref, childexpression, aggregatorfunc, childpredicateexpression) enabled for for a description of the business object categories, see notes on "enabled for" docid\ u26v9fecfs6ilwa0 pvjd business object category yes/no business rules before save rules yes business rules calculation rules (after save, with or without also recalculate on load) yes business rules calculation rules (before save or always, without also recalculate on load) yes business rules calculation rules (before save or always, with recalculate on load) yes business rules editing rules yes1 business rules initialization rules yes business rules read only rules no business rules required rules yes1 business rules validation rules yes client expressions no object permissions no services yes ldap yes mobile yes quick actions (except ui quick actions) yes ui quick actions no reports yes search/dashboard without field references yes search/dashboard with field references no 1 except when this field appears on a form or is triggered by such a field parameters parameter description parentobjectref the name of the parent business object parentrecid the recid of the instance of the parent business object relationshipkey a relationship key for the relationship relating the parent to its related object (child business object) childexpression the expression to evaluate for each child business object aggregatorfunc an aggregation function specified as a string in this release, supports the plus (+), sum, avg, average, min, max, count aggregator childpredicateexpression (optional) a boolean expression that is evaluated for each child the child is only included if the result of this evaluation is true return value unicode text value examples example 1 to determine the number of instances of the child business objects associated with a parent incident business object, enter the following $(childfold("incident#", "213kjasd92132sd", "task#assignment rev3", cost + 100, "+")) this looks up the incident business object where the recid is 213kjasd92132sd and finds all of the task business objects related to this change business object through the task#assignment rev3 relationship in the context of each of these child business objects, the function evaluates the expression cost + 100 and combines all of these computed values using addition example 2 to count all the task#assignment children that are not canceled, enter the following $(childfold("incident#", recid, "task#assignment rev3", 1, "sum", $(status != 'canceled'))) example 3 to update a field in the change business object to get a count of the incidents $(childfold("change#", recid, "incident# ", 1, "+", $(status != 'active'))) incident# is the relationship reference to the child incident business object, where the internal reference name for this relationship is empty if the internal reference name of the relationship is not empty, use instead incident# internal reference name , where the internal reference name is after the period if the relationship is to a group member business object such as frs knowledge issueresolution, you would use frs knowledge#issueresolution interna l reference name notice that the member business object is between the # and the in all examples advanced example to create a client side calculated value field (client visibility, or required rule) that uses the results of the childfold() function results (for example, if the visibility rule depends on the number of open tasks), follow these instructions since the childfold() function is not supported on clients, you can create a helper field, such as taskcount , and add a calculation rule that is evaluated on the server context to hide a button in the user interface based on the teams to which a user belongs, create a visibility rule when you refer to a calculated field value in a client side (visibility or read only) rule, the following happens if the field is an existing stored field, use the normal beforesave condition you do not need to select also recalculate on load if the field is intended for user interface visibility only, create a new field that is not stored with a calculation rule set to aftersave , by doing the following open the field, such as taskcount , and ensure that stored is not selected edit the calculation rule for that field, and set the condition to aftersave select also recalculate on load add the taskcount field as an invisible field to the header form of an incident add the user interface visibility rule to a form action now the button is only visible when the visibility rule returns false and it is hidden when the visibility rule returns true
