How to get weekly data for Tasks through Graphql

Hi All,

Can anyone please me that how to get weekly data for task which will be filter by Due date.

Example:

Tasks: Screenshot by Lightshot

Graphql: Screenshot by Lightshot

I am not able to find filter in Graphql list. Here is the exampl of code:

{% for test in taskCollectionData %}

{{test.hs_task_subject}}

{% endfor %}

Above condition is working fine but I need weekly data indead of all the task list.

Thanks in advance!

Hey @Priya07 ,

thank you for reaching out to the community.

Maybe I can help a little here. When you want to filter all tasks for each week, you need to find the timestamp for Monday 12am for your timezone first. After that, you need to use that timestamp in your query. For me, it looks something like this:

query MyQuery {
 CRM {
 task_collection(filter: {hs_createdate__gte: "1693180800000"}) {
 items {
 hs_createdate
 hs_object_id
 hs_task_subject
 }
 }
 }
}

Let us know if this helps.

Cheers,

Chriso

Hi @ChrisoKlepke ,

Thanks for sharing above solution.

I need to use UK timezone for weekly data. Can you help me with this please?

Best regards,

Priya

Hey,

you can look for this yourself and experiment with it here.

For this week, in GMT+1 it would be 1693226642. HubSpot works in milliseconds, so you have to add some zeros at the end. So 1693226642000

You very likely need to have a function looking for the respective Monday midnight time. Depending on what you’re building, there is very likely a library for that.

Make sure you filter on due date. In my example, I used create_date. Sorry about that.

If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I’d really appreciate it.

Cheers,

Chriso

query MyQuery {
 CRM {
 task_collection(orderBy: hs_timestamp__desc, limit: 5000, filter: {hubspot_owner_id__eq: "XXXXXXXX",hs_createdate__gte: "1693226642000"}) {
 items {
 hs_task_subject
 }
 }
 }
}

Hi @ChrisoKlepke ,

I tried with above code which you are provided but it doesn’t work for me:

Could you please look into this.

Thanks in advance!

Priya

Hey @Priya07

Can you get into more detail where you’re at and what doesn’t work precisely? It is very hard for us in the community to diagnose problems remotely already, but if you provide the most information possible, we can usually work out something. That is especially true for development stuff.

Looking forward hearing from you.

Cheers,

Chriso

Hi @ChrisoKlepke ,

Thanks for your response.

Here is the below code which I used for graphql file:

query CombinedQueries {
CRM {
task_collection(orderBy: hs_timestamp__desc, limit: 5000, filter: {hubspot_owner_id__eq: "XXXXXXXX"}) {
items {
hs_task_priority
hs_task_body
hs_task_subject
hs_timestamp
hs_task_type
hs_task_status
}
}
meeting_event_collection(orderBy: hs_meeting_start_time__desc, limit: 50, filter: {hubspot_owner_id__eq: "XXXXXXX"}) {
items {
hs_activity_type
hs_meeting_start_time
hs_meeting_title
hs_meeting_outcome
}
}
}
}

Output: https://prnt.sc/Oei5qbX_bhJP
Expectation: Screenshot by Lightshot

This output provided all data but I need weekly data for tasks filter by due date.

Let me know if you need anything.

Thanks in advance!

Priya