Service Manager

Home 

ChildFold

Iterates through the specified child business objects, evaluating the expression in the context of each of the child business objects. The results of the expression evaluations are aggregated using the aggregatorFunc parameter.

Evaluates an expression for each selected object instance related to (a child of) a parent business object and applies an aggregator function to the results. The childPredicateExpression parameter, if specified, selects which related objects to include. If not specified, they are all included.

In this release, Service Manager only supports the plus (+) aggregator operator. In the future, we may support additional aggregator operators such as multiplication (*), minimum (min), maximum (max), etc.

Syntax

ChildFold(parentObjectRef, parentRecId, childRelationshipRef, childExpression, aggregatorFunc, childPredicateExpression)

Enabled For

For a description of the business object categories, see Notes on "Enabled For".

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

parentObjectRef The name of the parent business object.
parentRecId The RecID of the instance of the parent business object.
childRelationshipRef

A relationship name 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, Service Manager only supports the plus (+) 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.

Example

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.

Another example counts all the "Task#Assignment" children that are not canceled.

$(ChildFold("Incident#", RecId, "Task#Assignment.Rev3", "1", "+", "$(Status != 'Canceled')"))

In another example, you can 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.Internal Reference Name. Notice that the member business object is between the # and the . in all examples.

Advanced Example

If you want to create a 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, do the following.

To hide a button in the user interface based on the teams to which a user belongs, create a visibility rule.  

As 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.

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 before save condition. You do not need to check 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 checked.

Edit the calculation rule for that field, and set the condition to AfterSave. Check 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.


Was this article useful?