CMS Development

MEmpeño
Member

crm_object function: Limit value overrides total value

SOLVE

Hi,

 

I need some help.

 

I have a job custom object and declared using crm_objects function. I noticed on the print that the limit value overides the offset value, and is not getting the correct total number of my custom job object.

 

{# Get job object #}
{% set jobs_init = crm_objects('job', 'offset=0&limit=20')%}
<p>{{jobs_init}} </p>

 

Print Result:
{has_more=true, offset=20, total=20, results=[{20 job result listed}]

 

-------------------------------------------------------------------------------------

I also tried calling the the job custom object without the offset and limit queries

 

{# Get job object #}
{% set jobs_init = crm_objects('job')%}
<p>{{jobs_init}} </p>

 

Print Result:

{has_more=true, offset=10, total=10, results=[{hidden}]}

This is the total number of jobs we have:

MEmpeo_0-1683645459467.png

 

Has anyone encountered the same issue and is there a fix?

1 Accepted solution
JBeatty
Solution
Guide | Diamond Partner
Guide | Diamond Partner

crm_object function: Limit value overrides total value

SOLVE

Hi @MEmpeño,

 

From the docs https://developers.hubspot.com/docs/cms/hubl/functions:

  • offset is the offset to use for the next batch of results.

So it is returning the offset you would use to get the next batch of objects. For example if you do:

{% set jobs_init = crm_objects('job', 'offset=20&limit=20') %}

You should get something like this:

{has_more=true, offset=40, total=20, results=[{20 job result listed}]

Let me know if I am misunderstanding what you are saying or if you have any other questions.


Best,

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk

View solution in original post

0 Upvotes
1 Reply 1
JBeatty
Solution
Guide | Diamond Partner
Guide | Diamond Partner

crm_object function: Limit value overrides total value

SOLVE

Hi @MEmpeño,

 

From the docs https://developers.hubspot.com/docs/cms/hubl/functions:

  • offset is the offset to use for the next batch of results.

So it is returning the offset you would use to get the next batch of objects. For example if you do:

{% set jobs_init = crm_objects('job', 'offset=20&limit=20') %}

You should get something like this:

{has_more=true, offset=40, total=20, results=[{20 job result listed}]

Let me know if I am misunderstanding what you are saying or if you have any other questions.


Best,

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk

0 Upvotes