# NodeJS Client Ticket Associations (DoSearch)

**URL:** <https://community.hubspot.com/t/nodejs-client-ticket-associations-dosearch/88235>\
**Category:** APIs & Integrations\
**Tags:** sdk\
**Created:** [August 24, 2023, 11:15am UTC](https://community.hubspot.com/t/nodejs-client-ticket-associations-dosearch/88235 "2023-08-24T11:15:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSixsmith](https://avatars.discourse-cdn.com/v4/letter/j/48db29/32.png) [@JSixsmith](https://community.hubspot.com/u/JSixsmith)\
**Post date:** [August 24, 2023, 11:15am UTC](https://community.hubspot.com/t/nodejs-client-ticket-associations-dosearch/88235/1 "2023-08-24T11:15:39Z")

</div>

Hey,

What is the correct way of, returning tickets using doSearch and bringing back associations?

For example, I want to Search for all Tickets and bring back the Association being Companies

I currently have this but, it is not working

```lia-code-sample
 const tickets = await this.hubspotClient.crm.tickets.searchApi.doSearch({
 after: after, filterGroups: [
 {
 filters: [
 {
 propertyName: "hs_lastmodifieddate",
 operator: "GTE",
 value: date
 }
 ],
 }
 ], limit: 100, properties: ticketProperties, sorts: undefined, query: "&associations=companies"
 });

```

I have tried a few values in the query section but nothing is working.

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [August 25, 2023, 3:12am UTC](https://community.hubspot.com/t/nodejs-client-ticket-associations-dosearch/88235/2 "2023-08-25T03:12:33Z")

</div>

Hi @JSixsmith 👋

As per HubSpot’s [CRM Search API doc](https://developers.hubspot.com/docs/api/crm/search), it’s only possible to return records of the object-type specified in the request path. For example, if the request path is _/crm/v3/objects/ **TICKETS** /search_, only **Tickets** can be returned in the response (i.e. not associated records of other object-types, like Companies).

You can however use the CRM Search API to _“search for records that are associated with other **specific records** by using the pseudo-property associations.{objectType}”_. Unfortunately, this doesn’t really align with your use case. I see 2 options to achieve your desired result (efficiency will depend on the data volumes you’re working with):

##### Option 1

_More efficient with **lower** data volumes_

1. [List Tickets](https://developers.hubspot.com/docs/api/crm/tickets) _(GET /crm/v3/objects/tickets?associations=company&limit=100)_
  - Go through all records on all pages of results, identifying Ticket records that meet your search criteria and locating the associated Company IDs along the way

##### Option 2

_More efficient with **higher** data volumes_

1. [CRM Search](https://developers.hubspot.com/docs/api/crm/search) Tickets _(POST /crm/v3/objects/TICKET/search)_, as per your required search criteria, then …
2. [Batch Read Associations](https://developers.hubspot.com/docs/api/crm/associations) _(POST /crm/v4/associations/TICKET/COMPANY/batch/read)_
  - Using the Ticket IDs responded from your previous search in your request body

I hope that proves useful. Please let me know if you have any follow-up questions.
