ForEachChild
5 min
iterates child business object instances and computes a text value for each of them these values are then optionally sorted, and then concatenated and separated by a specified delimiter evaluates a text valued expression for each related (child) business object and concatenates the results into a single text value the related objects are related to a single parent business object via the childrelationshipref parameter the children can be ordered by specifying one or more sort fields of the child object as ordering keys syntax foreachchild(parentobjectref, recid, childrelationshipref, childexpression, fieldandorder) 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 except when this field appears on a form or is triggered by such a field parameters parameter description parentobjectref the parent business object as an object reference recid recid of the parent business object instance childrelationshipref the relationship that relates the parent to its children childexpression an expression to evaluate for each child if the final element of the concatenation is the same for each instance and is a literal value, the application interprets that literal value to be a delimiter the application adds the delimiter to the end of every entry except for the last entry fieldandorder (optional) the order by which to sort the results each argument is a list of field names optionally followed by a space and asc (ascending) or desc (descending) ascending is the default this function can take an unlimited number of these parameters, including none use additional instances of this parameter to sort the results even more return value text value example for example, to iterate all instances of the resnotehistory child business object for a fixed issue with a certain recid, use the following within the business rule of the parent business object foreachchild("issue fix", recid, "resnotehistory# ", "lastmodby + '\t' \+ lastmoddatetime \+ '\r\n' + resolutionnote \+ '\r\n \r\n'", "createddatetime asc") for each instance, the application concatenates the following information the name of the person who last modified the instance (lastmodby), followed by a tab, followed by the date and time it was last modified (lastmoddatetime), followed by a new line, and then the text of the resolution note (resolutionnote), followed by a new line that contains an underline and followed by another new line these concatenations are sorted by the date and time the instance was created (createddatetime) in ascending (asc) order here is another example that puts all incident related configuration items into a single text field $(foreachchild("incident#", recid, "ci# ", "citype + '\t' + name + '\r\n' + ipaddress + '\t' + model +'\r\n \r\n'", "name asc"))
