APIs & Integrations

EJackson23
Participante

Limit the Number of For Loops

resolver

I'd like to limit the number of loops so it doesn't show more than 10 records. I've tried adding the range function but I'm not exactly sure where to put it. Thanks for you help.

 

{% set contact_id = contact.hs_object_id %}

{% set associated_objects = crm_associations(contact_id, 'USER_DEFINED', 30, 'orderBy=account_row_id', 'account_row_id,acct_uom,acct_commodity,lastmonth_date,lastmonth,thismonth_date,thismonth,month1,month1_date,month2,month2_date,month3,month3_date,month4,month4_date,month5,month5_date,month6,month6_date,month7,month7_date,month8,month8_date,month9,month9_date,month10,month10_date,month11,month11_date') %}

{% for energyresi in associated_objects.results %}

 

All my html

{% endfor %}

1 Solução aceita
himanshurauthan
Solução
Autoridade no assunto | Parceiro Elite
Autoridade no assunto | Parceiro Elite

Limit the Number of For Loops

resolver

Hello @EJackson23,

 

I would recommend limiting the results by 10 objects only, and you can do that like this example -

 

{% set associated_objects = crm_associations(contact_id, 'USER_DEFINED', 30, 'limit=10&orderBy=account_row_id', 'account_row_id,acct_uom,acct_commodity,lastmonth_date,lastmonth,thismonth_date,thismonth,month1,month1_date,month2,month2_date,month3,month3_date,month4,month4_date,month5,month5_date,month6,month6_date,month7,month7_date,month8,month8_date,month9,month9_date,month10,month10_date,month11,month11_date', false) %}

 

I hope this helps,

 

Have an amazing day ahead!

Digital Marketing & Inbound Expert In Growth Hacking Technology

Exibir solução no post original

3 Respostas 3
webdew
Orientador(a) | Parceiro Diamante
Orientador(a) | Parceiro Diamante

Limit the Number of For Loops

resolver

Hi @EJackson23 ,

This function returns an object with the following attributes: has_more, total, offset and results.
You can pass offset number in association hubl function:
Screen shot : https://prnt.sc/1gzol30


Please have look this documentation :
https://developers.hubspot.com/docs/cms/hubl/functions

Example :
{% set associated_objects = crm_associations(<contact_vid>, 'USER_DEFINED', 30, 'offset=<offset_interger>', false) %}

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

0 Avaliação positiva
himanshurauthan
Solução
Autoridade no assunto | Parceiro Elite
Autoridade no assunto | Parceiro Elite

Limit the Number of For Loops

resolver

Hello @EJackson23,

 

I would recommend limiting the results by 10 objects only, and you can do that like this example -

 

{% set associated_objects = crm_associations(contact_id, 'USER_DEFINED', 30, 'limit=10&orderBy=account_row_id', 'account_row_id,acct_uom,acct_commodity,lastmonth_date,lastmonth,thismonth_date,thismonth,month1,month1_date,month2,month2_date,month3,month3_date,month4,month4_date,month5,month5_date,month6,month6_date,month7,month7_date,month8,month8_date,month9,month9_date,month10,month10_date,month11,month11_date', false) %}

 

I hope this helps,

 

Have an amazing day ahead!

Digital Marketing & Inbound Expert In Growth Hacking Technology
EJackson23
Participante

Limit the Number of For Loops

resolver

Thank you Himanshu. This worked great.

0 Avaliação positiva