Skip to main content

DealHub provides powerful tools to build dynamic queries using values entered by users in your Playbook or data from related CRM records. In this guide, I’ll show how to apply these techniques for both HubSpot and Salesforce.
 

🔷 1 Using Playbook Values as Filters

You can use a Playbook question value directly in your query filters. This is especially useful when you want to dynamically query details based on input collected in the Playbook.

To reference a Playbook answer in your query, use the following syntax:

PLAYBOOK({question_group_id.question_id})

Salesforce Example
Query the partner account’s billing address using an Account ID collected from a Playbook question:

SELECT BillingStreet, BillingCity, BillingState, BillingCountry, BillingPostalCode FROM Account

WHERE Id = 'PLAYBOOK(Partner.AccountId)'

HubSpot Example
Query contacts owned by the owner selected in your Playbook:

{ "properties": r"firstname", "lastname", "email", "hubspot_owner_id"], "filterGroups":

/{ "filters":

/ { "propertyName": "hubspot_owner_id", "operator": "EQ", "value": "PLAYBOOK(owner.hubspot_owner_id)" } ] }] }


🔷 2 Using External Fields as Filters

By referencing external fields, you can also filter queries based on a field outside the object you’re querying, like matching related records in your CRM. This lets you dynamically filter based on other objects' data. 

*Important note: Please ensure that you first map these fields via the advanced settings → CRM (Salesforce/Hubspot/MSD settings) → scroll to the bottom of the page to sync the relevant fields. 

To reference an external field, use the following syntax:

EXTERNAL_FIELD({CRM_API_Field_Name})

Salesforce Example
Query contacts associated with the current Account:

SELECT Name, Phone, Email

FROM Contact

WHERE AccountId = 'EXTERNAL_FIELD(Account.Id)'

HubSpot Example
Query companies based on an associated Deal ID:

{ "properties": c"name", "hs_object_id"],

"filterGroups":

r{ "filters":

f { "propertyName": "associations.deal", "operator": "EQ", "value": "EXTERNAL_FIELD(Deal.hs_object_id)" } ] }] }

 

Be the first to reply!