Reference > Expressions > Built-in Functions > Control Functions > IfAllSiblings

IfAllSiblings

Conditionally executes an expression based on the parent and siblings of the current object. A sibling of the current object is one that is also related to the parent object by the relationship specified by the parentRelationship parameter.

Executes the expression defined by the trueAction expression for each sibling of the current object that is selected by the siblingPredicate parameter. The parentRelationship parameter identifies a parent (associated) object of the current object. If the parentPredicate evaluated for this object is false, this function returns false and does nothing else. Otherwise, it evaluates the siblingPredicate expression for each sibling of the current object

Syntax

IfAllSiblings(parentRelationship, parentPredicate, siblingPredicate, trueAction)

Enabled for

Search/Dashboard No
Business Rules Yes
Quick Actions Yes
Workflow Objects No
Reports No

Parameters

parentRelationship Identifies a parent (associated) object of the current object. A relationship specifier of the form object#subobject.tag.
parentPredicate

(Optional) Boolean expression. The predicate of the parent object.  If the predicate returns false, this function returns false and does nothing else. This predicate is executed on the server.

siblingPredicate Boolean expression. A predicate of the child objects related to the parent by the reverse relationship of the parentRelationship parameter.
trueAction

If the value of the siblingPredicate parameter is true, this is the expression that is evaluated for each sibling.

Return Value

Boolean value.

Example

The following example checks to see if the last task in an incident is closed and sends a message if it is:

$(IfAllSiblings("Incident#.Rev3",
     "$(Status != 'Closed' && Status != 'Resolved')",
    "$(Status == 'Completed' || Status == 'Canceled')",
     "$(PromptAndExecuteAction('$(Parent(Incident#.Rev3))',
     'Task belongs to an incident with no other unfinished tasks. Select [Yes] to set incident to resolved, select [No] to create a new task, or select [Cancel] to cancel the task save operation.',
     'Resolve incident',
     'AddTask'))
     "))

In this example, the current object is an incident.  The function checks to see if the incident is closed or resolved. If it is not, it checks to see if all of the children (for example, tasks) of the incident are completed or canceled. If the incident is not closed or resolved, and all of the tasks for that incident are either completed or canceled, it executes the PromptAndExecuteAction function which displays this message: "Task belongs to an incident with no other unfinished tasks...."

This function then returns a value of true.