Hi
do you know if you can count the results of a query in the marketing email ?
example below:
<p>You have purchased:</p> <ul>
<!-- {{#each contact.contact_product_productid}} -->
<li>{{this.name}}</li>
<!-- {{/each}} --> </ul>
some group by can have 3 results other 10 etc
do you know which function/method for "this" obj can be use to give you the results count ?
thank you
Thank you, as this is javascript / html I though there is a way to count {{this.xxx}} results and add further personalization based on results (if 1 or more)
I am new to marketing stuff but familiar with dynamics. I try to describe a strange limitation below:
1) we build segments and apply the query block for a subset of data, let's say target only contacts for products with product type = xxx
2) the segments contain contacts only (not all contacts but the contacts from 1)
3) when segment is used in a customer journey and sending a marketing email for contacts, for the iteration [tag:each] it's not possible to get the subset of data it will list all associated records (not possible to get only products with type =xxx unless hardcoded in the email body js/html)
4) the workaround found was to use an intermediary entity to keep the query block results and then use this in [tag:each] query but not sure if there is any solution out of the box
kind regards
Hi slx,
Unfortunately, you can't count query results directly in marketing emails, there is no OOB function to do so currently.
It is recommended to create a custom field that type is rollup in Contact entity, which records the count of products.
Edit it as the following screenshot.
Note: The default recurrence of the rollup calculation is 1 hour. You can change this with following steps:
Then you can use the following code into the marketing email to show the number of related products:
{{contact.new_countofproducts}}
Result:
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,836
Most Valuable Professional
nmaenpaa
101,156