Query extension example for a Related People tab

In this article

When creating a Related People tab in a Coveo for Salesforce panel, you must specify a query to return search results of type People that are related to the currently selected case or account in Salesforce.

The following query example retrieves people relative to the currently selected case.

{{relatedItems=$correlateResultSet(resultSet: @sfid=="{!Id}", field: '@sysconcepts', maximumValues: '25', modifier: '10000')
               $correlateUsingIdf(keywords: "{!>Subject}")
               (@objecttype==case OR @objecttype==kb)
               (NOT @sfid=={!Id})}}
{{authorsOfRelatedItems=$valuesOfField(resultSet: {{relatedItems}}, field: '@sfownerid', maximum: '25', sortOrder: 'SortByScore')}}
$valuesToResultSet(values: {{authorsOfRelatedItems}}, field: '@sfid')

This query lists people that are owners of content related to the currently selected case.

In more details:

  • Line 1 to 4 find other cases or knowledge base (kb) items sharing the concepts and keywords of the subjects of the currently selected case.

  • Line 5 extracts the most relevant owners of these related cases or knowledge base (kb) items.

  • Line 6 transforms the list of owner values into a result set.

The previous query provides the relevant users to show in the Related People tab. After that, you must specify a second query that determines the items to list in relation with the selected people for each Insight Box that you add to the Related People tab.

The following query lists related cases for the selected expert.

$type(name:'Case') (NOT @sfid=="{!Id}")
$correlateUsingIdf(keywords: '{!>Subject} {!>Description}')
$correlateResultSet(resultSet: @sfid=={!Id}, field: '@sysconcepts', maximumValues: '25', modifier: '10000')

The %sfuserid% line filters results for the person that the user selects in the Related People tab.