Learn more about DocMergy Search by unique ID feature
Search By Unique IDs
Get singular version
Search for the unique ID of and show first name {{ search_by_unique_ids(“contact”,[ 80716298250 ])[0].firstname }}
- This shows the first name of the contact with the HubSpot ID: 80716298250
search_by_unique_ids("contact", [80716298250])
This is a HubL function (used in HubSpot custom coded templates or modules) that:
- Searches for contacts using their unique internal ID(s).
- The second parameter is an array ([80716298250]) — it allows for multiple IDs, even though here you're just using one.
[0].firstname }}
- [0]: Because the function returns a list of contacts, [0] grabs the first contact in the result (in this case, the only one).
- .firstname: This accesses the first name property of the retrieved contact.
For loop version
- This loops through a list of contacts (looked up by their IDs) and displays their first name, last name, and email address.
- search_by_unique_ids("contact", [80716298250, 86257912096]): Searches for multiple contacts based on their internal HubSpot contact IDs.
- {% for c in ... %} : Starts a loop that goes through each contact returned.
- {{ c.firstname }} {{ c.lastname }} {{ c.email }} : Displays each contact’s name and email.
- {% endfor %} : Ends the loop.
For loop images
- For each contact with the given IDs, show their first name, last name, and profile picture
- search_by_unique_ids("contact", [...]): Looks up the contacts based on HubSpot contact IDs.
- : Ends the loop.
For looping images you will need to create a property with a public URL linking to an image. You can upload an image to HubSpot files, get the URL and put it in the property you made.
You will then need to create the custom relevant custom token which is associated to the property you made eg. Object profile picture URL and then put that in the ALT text for the image
If you right click on the image you need to insert what the token would be for the custom property you made, except “object.” It needs to be “c.profile_picture” so its taking the other contacts URL and not the contact that is enrolled.
Deal Examples
Get singular version
- This shows the deal name of the with the HubSpot ID: 32226481156
Search for the unique ID of and show me the deal name: {{ search_by_unique_ids(“deal”,[ 32226481156 ])[0].dealname }}
- search_by_unique_ids("deal", [32226481156]): This retrieves a list of deals using their unique HubSpot IDs. In this case, just one deal.
- [0]: Accesses the first (and only) deal in the list.
- .dealname: Gets the name of that deal.
For loop version
- Loop through two specific deals, identified by their HubSpot object IDs (32226481156 and 35640046409), getting the deal name, deal amount and deal close date and store each one in the variable c for use inside the loop.
- search_by_unique_ids("deal", [...]): Looks up deals by their internal HubSpot IDs.
- {% for c in ... %} : Begins a loop over each deal retrieved.
- {{ c.dealname } : Outputs the name of the deal.
- {{ c.amount }} : Outputs the amount (usually in the deal's currency).
- {{ c.closedate }} : Outputs the date the deal was or will be closed.
- {% endfor %} : Ends the loop.
For loop images
- This loop grabs two specific deals by their HubSpot IDs and displays each deals name, amount and converting the ‘product picture URL’ to a visible image
- search_by_unique_ids("deal", [...]): Looks up deals by their internal HubSpot IDs.
- {% for c in ... %} : Loops through each retrieved deal.
- {{ c.dealname }} : Shows the deal name.
- {{ c.amount }} : Displays the deal amount.
- {{ c.product_image_url }} : Outputs the image that has the URL stored on the object from a custom property
- {% endfor %} : Ends the loop
- You will need to create a custom property for this called: ‘Product Image URL’ with the internal name being ‘product_image_url’
- Upload some images to HubSpot files, grab the URL and paste it into the property on the two deals. To see the demo get two random images and put each URL on two different deals.
- Put the token {{ c.product_image_url }} in the image alt text below. It needs to be “c.” so its taking the other deals URL and not just the deal that is enrolled