# Display Associations Array Value

**URL:** <https://community.hubspot.com/t/display-associations-array-value/77701>\
**Category:** APIs & Integrations\
**Tags:** object, professional\
**Created:** [March 22, 2023, 4:28am UTC](https://community.hubspot.com/t/display-associations-array-value/77701 "2023-03-22T04:28:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jun22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jun22/32/34870_2.png) [@Jun22](https://community.hubspot.com/u/Jun22)\
**Post date:** [March 22, 2023, 4:28am UTC](https://community.hubspot.com/t/display-associations-array-value/77701/1 "2023-03-22T04:28:24Z")

</div>

Hello Guys Need Help,  
I made display the deals associated with the company using API integrations I have api endpoint below with “Properties and Asssociations”.

`https://api.hubapi.com/crm/v3/objects/deals?limit=10&properties=hubspot_owner_id&pro[…]ge&associations=companies&associations=contact&archived=false`

I have image below with a deal and I need to get the company name and associated contact from the deal. It display on array display the properties value like dealname is showing. But when try to pull the data on “associations” like. contact, company it shows undefine  
here’s my sample code to pull the Properties and Associations from a table only associations is not working:

```lia-code-sample
var table = document.getElementById("demoB").getElementsByTagName('tbody')[0];
 filtered_results.forEach((element, index, array) => {

var row = table.insertRow();
var cell = row.insertCell();

cell.innerHTML = element['associations']['company'];
cell = row.insertCell();
cell.innerHTML = element['properties']['hubspot_owner_id'];​

```

The ['‘associations’][‘company’] is showing **underfined.**  
while properties is showing. 😔

 ![Jun22_1-1679459182448.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/6/c67f269e59dda6cca3aa3113036f114156805a2d.png)  
 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/e/8ee7e2eb58f62f0fb69fba562f09dcd24aa4fbf4.png)

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/9/d95fcb30f6c099cb90bbce3b4fafeaa244a2ef28.png)

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [March 22, 2023, 7:26pm UTC](https://community.hubspot.com/t/display-associations-array-value/77701/2 "2023-03-22T19:26:11Z")

</div>

Hi, @Jun22 👋 Thanks for reaching out. Let’s see if any of our community members have any JavaScript magic they can offer — hey @miljkovicmisa @MatthiasWeber @albertsg, do you have any experience here?

Thank you! — Jaycee

---

<div class="post-metadata">

**Author:** ![albertsg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/albertsg/32/99473_2.png) [@albertsg](https://community.hubspot.com/u/albertsg)\
**Post date:** [March 23, 2023, 10:06am UTC](https://community.hubspot.com/t/display-associations-array-value/77701/3 "2023-03-23T10:06:39Z")

</div>

Hello @Jun22, I believe you are not accessing properly the values inside ‘associations’. Notice that the structure of ‘associations’ and ‘properties’ is different.

I recommend you to debug it by printing every “step” with console.log to see where you are not accessing the data properly.

Also, take a look at the accepted solution here, I’m sure it will help: [https://stackoverflow.com/questions/11922383/how-can-i-access-and-process-nested-objects-arrays-or-json](https://stackoverflow.com/questions/11922383/how-can-i-access-and-process-nested-objects-arrays-or-json)

---

<div class="post-metadata">

**Author:** ![Jun22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jun22/32/34870_2.png) [@Jun22](https://community.hubspot.com/u/Jun22)\
**Post date:** [March 24, 2023, 6:21am UTC](https://community.hubspot.com/t/display-associations-array-value/77701/4 "2023-03-24T06:21:22Z")

</div>

Hello albertsg,  
Thanks i get now the results with similar documentation of the link you just shared. And it returns now with ID,  
do you have any reference now that we can retrieved the deals endpoint to display Label name instead of ID’s e.g “Owner Name, Company Name, and Contact Name.”

---

<div class="post-metadata">

**Author:** ![GRajput](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grajput/32/102020_2.png) [@GRajput](https://community.hubspot.com/u/GRajput)\
**Post date:** [April 5, 2023, 1:05pm UTC](https://community.hubspot.com/t/display-associations-array-value/77701/5 "2023-04-05T13:05:35Z")

</div>

Hi @Jun22

Based on the code snippet you provided, it looks like you are trying to access the value of the “company” property from the “associations” object in your API response.  
One possible reason why you are getting an “undefined” value for “element[‘associations’][‘company’]” could be that the “associations” object does not have a “company” property. You can check the structure of the “associations” object by logging it to the console and see if it has a “company” property or not.  
Another possible reason could be that the “company” property exists but its value is null or undefined in the API response. You can again log the value of “element[‘associations’][‘company’]” to the console and check if it is null or undefined.  
If you confirm that the “associations” object does have a “company” property and its value is not null or undefined, you can try accessing it using dot notation instead of bracket notation, like this:

cell.innerHTML = element.associations.company;  
If dot notation still doesn’t work, you can also try using the “getProperty” method of the “associations” object to access the value of the “company” property, like this:

arduino

cell.innerHTML = element.associations.getProperty(‘company’);  
Make sure to also check that the API endpoint you are using actually returns the “company” property in the “associations” object. If it doesn’t, you might need to modify your API query to include the “company” property.

Please mark it as SOLUTION ACCEPTED if you like the solution.

Thank you!
