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:
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. 😔
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.
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.
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.
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.
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."
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?