searchFlexibleHierarchy(hierarchyId, searchQuery, entityType)

Search the nodes in a flexible hierarchy to find the nodes by the name of their reference record, filtered by object type.

API Version 

68.0

Requires Chatter 

No

Signature 

public static ConnectApi.FlexibleHierarchySearchRepresentation searchFlexibleHierarchy(String hierarchyId, String searchQuery, String entityType)

Parameters 

hierarchyId

Type: String

ID of the flexible hierarchy to search within.

searchQuery

Type: String

Text to search in the name of the reference records of the flexible hierarchy nodes.

entityType

Type: String

API name of the object whose nodes to search.

Return Value 

Type: ConnectApi.FlexibleHierarchySearchRepresentation

Example 

1public static void sample_searchFlexibleHierarchy() {
2    ConnectApi.FlexibleHierarchySearchRepresentation result =
3        ConnectApi.FlexibleHierarchyConnect.searchFlexibleHierarchy(
4            HIERARCHY_ID,
5            'AS-DACH',
6            'Account'
7        );
8
9    System.debug('Status Code: ' + result.responseStatus.statusCode);
10    System.debug('Message: ' + result.responseStatus.message);
11
12    if (result.matchingNodes != null) {
13        System.debug('Match Count: ' + result.matchingNodes.size());
14
15        for (ConnectApi.FlexibleHierarchySearchNodeRepresentation node : result.matchingNodes) {
16            System.debug('Node ID: ' + node.nodeId);
17            System.debug('Reference Record: ' + node.referenceRecord);
18        }
19    } else {
20        System.debug('Match Count: 0');
21    }
22}