APIs & Integrations

EJackson23
参加者

Limit the Number of For Loops

解決

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件の承認済みベストアンサー
himanshurauthan
解決策
ソートリーダー | Elite Partner
ソートリーダー | Elite Partner

Limit the Number of For Loops

解決

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

元の投稿で解決策を見る

3件の返信
webdew
ガイド役 | Diamond Partner
ガイド役 | Diamond Partner

Limit the Number of For Loops

解決

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 いいね!
himanshurauthan
解決策
ソートリーダー | Elite Partner
ソートリーダー | Elite Partner

Limit the Number of For Loops

解決

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
参加者

Limit the Number of For Loops

解決

Thank you Himanshu. This worked great.

0 いいね!