Export in Google Sheet Contacts with Associated Company
These are strings of my Apps Script where I am trying to export in google sheet the contacts in the CRM. It works fine, but how can I add also the property of the Associated Company?
var url_query = API_URL + "/contacts/v1/lists/all/contacts/all";
var firstName = (item.properties.hasOwnProperty('firstname')) ? item.properties.firstname.value : "NA"; var lastName = (item.properties.hasOwnProperty('lastname')) ? item.properties.lastname.value : "NA"; var company = (item.properties.hasOwnProperty('company')) ? item.properties.company.value : "NA"; var email = "NA";
Export in Google Sheet Contacts with Associated Company
If you are looking for a one-time solution, you can export all of your CRM data to Excel and open the file in Google Sheets. Here's a link to another community post about the free Ultimate Data Export app. NEW! Export raw web events associated with HubSpot CRM data
Did this post help solve your problem? If so, please mark it as a solution.
John Elmer, CEO Bayard Bradford Advanced CRM Implementation | HubSpot Custom Integration Services | Datawarehouse.io Apps for HubSpot Elite HubSpot Solutions Partner > Follow me on LinkedIn
Export in Google Sheet Contacts with Associated Company
If it's not a a property of the contact you can't get it through a contact request. This part of the hubspot ui is called an association and can be retrieve with this request on the new api:
Make for each contact a request of the company data according to the associatedcompanyid field and retrieve the name
Make a request to get all companies, store in a table and in your contact loop pick in your table companie information according to the associatedcompanyid
The first choice need lot of request, the second one, manage pagination to get all company in a single array
Export in Google Sheet Contacts with Associated Company
The field that you can see in the picture is not a property of the contacts. I thought that this field could be the associatedcompany property and not the company ID, but as I said, I need the name of the company for that value in the picture.
Export in Google Sheet Contacts with Associated Company
I'm not sure that this data is a field of the contact object... I need to investigate more, but at the moment with the information you get with the associatedcompany id you can make a request to get the company information and his name
var url_query = API_URL + "/contacts/v1/lists/all/contacts/all&property=associatedcompanyid";
if (hasMore)
{
url_query += "&vidOffset="+offset;
}
I added the new parameters in the url api, and now because the url already have a parameters i change in the following condition the "?" parameters by a "&"