<?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 Unable to find company associated to deal in Workflow Custom Code action in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Unable-to-find-company-associated-to-deal-in-Workflow-Custom/m-p/1152820#M82133</link>
    <description>&lt;P class=""&gt;Hello HubSpot team,&lt;/P&gt;&lt;P class=""&gt;I am building a custom automation inside a Workflow Custom Code action to synchronise revenue share values from a partner company record into the company associated to a deal.&lt;/P&gt;&lt;P class=""&gt;My intended flow is:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Read the partner company name from a field on the deal&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Use HubSpot’s Search API to find the partner company record by name&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Retrieve the company associated to the triggering deal&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Copy key property values (e.g. revenue share type and amount) from the partner company into the associated company record&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Originally I tried this by using “Edit Record” → “Associated Company” in the workflow, but&amp;nbsp;the action failed to update the record, even though I could retrieve the values from the partner company data in the workflow.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;I am now trying to update the associated company directly using HubSpot’s custom code action, using this approach:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;const associations = await client.crm.associations.v4.basicApi.getPage(&lt;BR /&gt;'deal',&lt;BR /&gt;triggerId,&lt;BR /&gt;'company'&lt;BR /&gt;);&lt;BR /&gt;const associatedCompanyId = associations.results?.[0]?.id;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;However, no matter what I try, I always get either:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;associations.results is empty&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;results[0].id is undefined&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;Even though I know (and can see in the UI + API Explorer) that the deal is associated to a company.&lt;/P&gt;&lt;P class=""&gt;My portal does have linked labels / custom association labels between deals and companies (like “Partner Company” or “Customer Company”).&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Could you please advise:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;What is the officially recommended pattern in 2025 to reliably get the associated company ID from a deal inside a workflow custom code action?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Is my intented flow the right to go about it ?&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thank you so much for your help!&lt;/P&gt;</description>
    <pubDate>Thu, 15 May 2025 09:34:50 GMT</pubDate>
    <dc:creator>CHamelin</dc:creator>
    <dc:date>2025-05-15T09:34:50Z</dc:date>
    <item>
      <title>Unable to find company associated to deal in Workflow Custom Code action</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Unable-to-find-company-associated-to-deal-in-Workflow-Custom/m-p/1152820#M82133</link>
      <description>&lt;P class=""&gt;Hello HubSpot team,&lt;/P&gt;&lt;P class=""&gt;I am building a custom automation inside a Workflow Custom Code action to synchronise revenue share values from a partner company record into the company associated to a deal.&lt;/P&gt;&lt;P class=""&gt;My intended flow is:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;Read the partner company name from a field on the deal&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Use HubSpot’s Search API to find the partner company record by name&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Retrieve the company associated to the triggering deal&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;Copy key property values (e.g. revenue share type and amount) from the partner company into the associated company record&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Originally I tried this by using “Edit Record” → “Associated Company” in the workflow, but&amp;nbsp;the action failed to update the record, even though I could retrieve the values from the partner company data in the workflow.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;I am now trying to update the associated company directly using HubSpot’s custom code action, using this approach:&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;const associations = await client.crm.associations.v4.basicApi.getPage(&lt;BR /&gt;'deal',&lt;BR /&gt;triggerId,&lt;BR /&gt;'company'&lt;BR /&gt;);&lt;BR /&gt;const associatedCompanyId = associations.results?.[0]?.id;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;However, no matter what I try, I always get either:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;associations.results is empty&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;results[0].id is undefined&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;Even though I know (and can see in the UI + API Explorer) that the deal is associated to a company.&lt;/P&gt;&lt;P class=""&gt;My portal does have linked labels / custom association labels between deals and companies (like “Partner Company” or “Customer Company”).&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Could you please advise:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P class=""&gt;What is the officially recommended pattern in 2025 to reliably get the associated company ID from a deal inside a workflow custom code action?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;Is my intented flow the right to go about it ?&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thank you so much for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 15 May 2025 09:34:50 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Unable-to-find-company-associated-to-deal-in-Workflow-Custom/m-p/1152820#M82133</guid>
      <dc:creator>CHamelin</dc:creator>
      <dc:date>2025-05-15T09:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to find company associated to deal in Workflow Custom Code action</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Unable-to-find-company-associated-to-deal-in-Workflow-Custom/m-p/1152901#M82139</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/942439"&gt;@CHamelin&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you tried using &lt;STRONG&gt;getAll()&lt;/STRONG&gt; instead of &lt;STRONG&gt;basicApi.getPage()&lt;/STRONG&gt; ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your associations&amp;nbsp;uses custom labels such as "Partner Company" or "Customer Company", then it might be the reason why you are seeing empty results.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is an example of how this could look like with using getAll():&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;const TARGET_ASSOCIATION_TYPE_ID = 27;

const associations = await client.crm.associations.v4.getAll('deal', triggerId, 'company');

const filtered = associations.results.find(
  assoc =&amp;gt; assoc.associationTypeId === TARGET_ASSOCIATION_TYPE_ID
);

const associatedCompanyId = filtered?.toObjectId;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;TARGET_ASSOCIATION_TYPE_ID should match the ID of the association label you are trying to target, which you can retrieve by doing a&amp;nbsp;GET on the /crm/v4/associations/deal/company/labels endpoint.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 May 2025 13:18:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Unable-to-find-company-associated-to-deal-in-Workflow-Custom/m-p/1152901#M82139</guid>
      <dc:creator>evaldas</dc:creator>
      <dc:date>2025-05-15T13:18:20Z</dc:date>
    </item>
  </channel>
</rss>

