<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get the deal's associated company name? in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686241#M56366</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/101258"&gt;@Teun&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for the information you provided. That's very helpful and it worked for me to get the default properties of the company.&lt;/P&gt;&lt;P&gt;Also, I would like to know how we can use the record ID which we got in the first call.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, below is the result from the first call, and in the result, we can see the record ID of the company. This record ID should be included in the second call to get the company properties. The second URL (&lt;STRONG&gt;&lt;A href="https://api.hubapi.com/crm/v3/objects/companies/" target="_blank"&gt;https://api.hubapi.com/crm/v3/objects/companies/&lt;/A&gt;&amp;lt;companyID&amp;gt;?archived=false&lt;/STRONG&gt;) should be dynamic.&amp;nbsp; The company ID here in the URL should be the record ID from the first call result. I'm new to HubSpot and trying to know more. Please let me know if this can be done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"results": [&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"toObjectId": 98445322,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"associationTypes": [&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"category": "HUBSPOT_DEFINED",&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"typeId": 0,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"label": "string"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Aug 2022 09:39:03 GMT</pubDate>
    <dc:creator>OLIVESHARON</dc:creator>
    <dc:date>2022-08-29T09:39:03Z</dc:date>
    <item>
      <title>How to get the deal's associated company name?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686200#M56357</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to get the deal's associated company name by using the below code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;var http = require("https");&lt;/P&gt;&lt;P&gt;var options = {&lt;BR /&gt;"method": "GET",&lt;BR /&gt;"hostname": "api.hubapi.com",&lt;BR /&gt;"port": null,&lt;BR /&gt;"path": "/crm/v4/objects/deal/"+event.inputFields['hs_object_id']+"/associations/company?limit=500",&lt;BR /&gt;"headers": {&lt;BR /&gt;"accept": "application/json",&lt;BR /&gt;"authorization": "access - token"&lt;BR /&gt;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var req = http.request(options, function (res) {&lt;BR /&gt;var chunks = [];&lt;/P&gt;&lt;P&gt;res.on("data", function (chunk) {&lt;BR /&gt;chunks.push(chunk);&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;res.on("end", function () {&lt;BR /&gt;var body = Buffer.concat(chunks);&lt;BR /&gt;console.log(body);&lt;/P&gt;&lt;P&gt;});&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;req.end();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;But in the result, I'm getting the record ID of the company which is associated with the deal which is absolutely fine.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Result :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"results": [&lt;BR /&gt;{&lt;BR /&gt;"toObjectId": 98445322,&lt;BR /&gt;"associationTypes": [&lt;BR /&gt;{&lt;BR /&gt;"category": "HUBSPOT_DEFINED",&lt;BR /&gt;"typeId": 0,&lt;BR /&gt;"label": "string"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"paging": {&lt;BR /&gt;"next": {&lt;BR /&gt;"after": "string",&lt;BR /&gt;"link": "string"&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now is there any possibility to get the '&lt;STRONG&gt;Company Name' in the result&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Or is there any way to get the&lt;STRONG&gt; 'Company Name' using the record ID of the company which we got in the result?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 08:08:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686200#M56357</guid>
      <dc:creator>OLIVESHARON</dc:creator>
      <dc:date>2022-08-29T08:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the deal's associated company name?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686205#M56358</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/438185"&gt;@OLIVESHARON&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The association API will only return ID's, so you will need a second API call to get the company name. And yes, you can use the ID you got in the first call to get the company name.&lt;/P&gt;
&lt;P&gt;Just make a second call to&amp;nbsp;'&lt;A href="https://api.hubapi.com/crm/v3/objects/companies/" target="_blank"&gt;https://api.hubapi.com/crm/v3/objects/companies/&lt;/A&gt;&amp;lt;companyID&amp;gt;?archived=false' to retrieve the default properties of the company.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 08:22:55 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686205#M56358</guid>
      <dc:creator>Teun</dc:creator>
      <dc:date>2022-08-29T08:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the deal's associated company name?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686241#M56366</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/101258"&gt;@Teun&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for the information you provided. That's very helpful and it worked for me to get the default properties of the company.&lt;/P&gt;&lt;P&gt;Also, I would like to know how we can use the record ID which we got in the first call.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, below is the result from the first call, and in the result, we can see the record ID of the company. This record ID should be included in the second call to get the company properties. The second URL (&lt;STRONG&gt;&lt;A href="https://api.hubapi.com/crm/v3/objects/companies/" target="_blank"&gt;https://api.hubapi.com/crm/v3/objects/companies/&lt;/A&gt;&amp;lt;companyID&amp;gt;?archived=false&lt;/STRONG&gt;) should be dynamic.&amp;nbsp; The company ID here in the URL should be the record ID from the first call result. I'm new to HubSpot and trying to know more. Please let me know if this can be done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"results": [&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"toObjectId": 98445322,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"associationTypes": [&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"category": "HUBSPOT_DEFINED",&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"typeId": 0,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"label": "string"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 09:39:03 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686241#M56366</guid>
      <dc:creator>OLIVESHARON</dc:creator>
      <dc:date>2022-08-29T09:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the deal's associated company name?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686301#M56371</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/438185"&gt;@OLIVESHARON&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example using Axios, I prefer it over https, but should help you out. I'm also using the v3 version of the API:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;const axios = require('axios')

const associatedCompanies = []

const associatedCompanyIDs = await axios({
  method: 'get',
  url: `https://api.hubapi.com/crm/v3/objects/deals/${event.inputFields['hs_object_id']}/associations/company?limit=500`,
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  }
}).then((response) =&amp;gt; {
  console.log(`Retrieved ${response.data.results.length} associated companies for deal: ${event.inputFields['hs_object_id']}`)
  return response.data.results
}).catch((error) =&amp;gt; {
  console.log(`Error while retrieving associated companies for deal ${event.inputFields['hs_object_id']}: ${error.response.data.message}`)
  return false
})

if (associatedCompanyIDs) {
  const data = {
    properties: [
      'name',
      'domain'
    ],
    inputs: associatedCompanyIDs.map((associatedCompanyID) =&amp;gt; { return { id: associatedCompanyID.id } })
  }

  associatedCompanies = await axios({
		method: 'post',
		url: `https://api.hubapi.com/crm/v3/objects/companies/batch/read`,
		headers: {
			'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
		},
    data: JSON.stringify(data)
	}).then((response) =&amp;gt; {
    console.log(`Retrieved ${response.data.results.length} associated companies for deal: ${event.inputFields['hs_object_id']}`)
    return response.data.results
  }).catch((error) =&amp;gt; {
    console.log(`Error while retrieving associated companies for deal ${event.inputFields['hs_object_id']}: ${error.response.data.message}`)
    return false
  })

  console.log(associatedCompanies)
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 29 Aug 2022 12:53:15 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686301#M56371</guid>
      <dc:creator>Teun</dc:creator>
      <dc:date>2022-08-29T12:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the deal's associated company name?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686396#M56383</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/101258"&gt;@Teun&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a million, the solution helped me to achieve my requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Aug 2022 15:35:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-to-get-the-deal-s-associated-company-name/m-p/686396#M56383</guid>
      <dc:creator>OLIVESHARON</dc:creator>
      <dc:date>2022-08-29T15:35:19Z</dc:date>
    </item>
  </channel>
</rss>

