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

FindAncestor

Returns the closest ancestor of a specified object instance in a hierarchy of objects.

For each ancestor object going upward from a starting object, this function evaluates the searchPredicate on the related object. If a hierarchy object is not related to one of the related objects, it is skipped.

Syntax

FindAncestor(hierarchyBoRef, relatedBoRef, recId, searchPredicate)

Enabled for

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

Parameters

hierarchyObjectRef The name of the business object (the starting object) that forms the hierarchy in which to find the ancestor. This is not an object reference.
relatedObjectRef The name of the related business object.
recId The RecId of the hierarchy business object instance.
searchPredicate (Optional)  Boolean filter expression to evaluate on the related object.

Return Value

Text value. The RecID of the ancestor instance found.

Example

$(FindAncestor("Frs_CompositeContract_Entity", "ServiceAgreement", EntityLink_RecID,

"$((ServiceLink == [OtherObject]Service_Valid) && (Status == \"Published\"))"

))

In the example above, the system goes up the entity chain looking for an object related to a published service agreement.