Handlebar Helper Function: Query

Retrieves multiple records from Sales Cloud or marketing object data sources. Use this helper to fetch arrays of records based on criteria that you specify.

This helper is available in the Summer ’26 release of Marketing Cloud Next (API version 67.0).

ParameterTypeDescription
fieldsStringA comma-separated list of field names to retrieve from the matching records.
idStringThe Salesforce ID of the target object. Use this parameter only when type is CRM.
limitIntegerThe maximum number of records to return in the query. If the value of type is CRM, the default value is 100.
objectStringRequired. The API name of the target object.
paramsObjectParameter values for where placeholders. Every parameter name in the where clause must have a corresponding key. See Params Values.
sortByStringIndicates the sort order to apply to results. Specify a field name followed by ASC (ascending order) or DESC (descending order). Use this parameter only when type is CRM. The default sort order is ASC.
typeStringRequired. The type of data source to query. Possible values: CRM (for Sales Cloud objects) or MO (for marketing objects).
whereStringA filter for the query. Use :paramName placeholders. Can’t be combined with inline field conditions or the id parameter. See Where Clause Syntax.

The where parameter supports these elements:

  • Operators: =, !=, <, >, <=, >=, LIKE
  • Logic: AND and OR
  • Placeholders: :paramName values that match keys in the params object

You can use parentheses to create logical groupings. For example, to add a filter that includes active records and either the Revenue value or the CreationDate value is greater than a specified parameter, use Status = "Active" AND (Revenue > 100000 OR CreationDate > "2025-01-01").

Use the hash function to specify parameters. This example uses the hash function to create an object with two properties: name and status. The where statement then refers to these parameters.

The function returns an array of matching records. If no records match the criteria, it returns an empty array [].

This example retrieves results from the Contact object that match a specific ID in Sales Cloud.

This example retrieves records from the Contact object and sorts them in ascending order by the LastName field. It then returns the first 10 results.

This example retrieves objects from the Account object where the value of the minRev property is greater than 1,000,000 and the value of the status property is Active.