<?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 Issues with making custom code workflow in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-making-custom-code-workflow/m-p/1097292#M79662</link>
    <description>&lt;P&gt;Hey all, I am making a custom code to get all the line items associated with a deal in one string and then add them to a sheet in another step and I am a bit stuck in it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;this is the error I'm getting:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;2025-01-21T09:38:08.256Z	ERROR	Error in workflow execution: hubspotClient.crm.associations.getAll is not a function

Memory: 79/128 MB
Runtime: 753.15 ms&lt;/PRE&gt;&lt;P&gt;and here is the code:&lt;/P&gt;&lt;P&gt;const hubspot = require('@hubspot/api-client');&lt;/P&gt;&lt;P&gt;exports.main = async (event, callback) =&amp;gt; {&lt;BR /&gt;const hubspotClient = new hubspot.Client({ accessToken: process.env.HSAPISara });&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt;// Retrieve the deal ID from the workflow event&lt;BR /&gt;const dealId = event.object.objectId;&lt;/P&gt;&lt;P&gt;// Get associated line items&lt;BR /&gt;const associationsResponse = await hubspotClient.crm.associations.getAll("deal", dealId, "line_item");&lt;/P&gt;&lt;P&gt;if (!associationsResponse || !associationsResponse.results) {&lt;BR /&gt;throw new Error("No associated line items found.");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const lineItemIds = associationsResponse.results.map(association =&amp;gt; association.id);&lt;/P&gt;&lt;P&gt;// Fetch line item details&lt;BR /&gt;const lineItemPromises = lineItemIds.map(async lineItemId =&amp;gt; {&lt;BR /&gt;const lineItemResponse = await hubspotClient.crm.lineItems.basicApi.getById(lineItemId, ["name"]);&lt;BR /&gt;&lt;BR /&gt;if (!lineItemResponse || !lineItemResponse.body || !lineItemResponse.body.properties) {&lt;BR /&gt;throw new Error(`Line item with ID ${lineItemId} is missing properties.`);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;return lineItemResponse.body.properties.name;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const lineItemNames = await Promise.all(lineItemPromises);&lt;/P&gt;&lt;P&gt;// Return the line item names&lt;BR /&gt;callback(null, {&lt;BR /&gt;outputFields: {&lt;BR /&gt;line_items: lineItemNames.join(", ")&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;} catch (error) {&lt;BR /&gt;console.error("Error in workflow execution:", error.message);&lt;BR /&gt;callback(error);&lt;BR /&gt;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;I would really appreciate it if anyone can help me with this.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jan 2025 10:28:42 GMT</pubDate>
    <dc:creator>sflht</dc:creator>
    <dc:date>2025-01-21T10:28:42Z</dc:date>
    <item>
      <title>Issues with making custom code workflow</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-making-custom-code-workflow/m-p/1097292#M79662</link>
      <description>&lt;P&gt;Hey all, I am making a custom code to get all the line items associated with a deal in one string and then add them to a sheet in another step and I am a bit stuck in it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;this is the error I'm getting:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;2025-01-21T09:38:08.256Z	ERROR	Error in workflow execution: hubspotClient.crm.associations.getAll is not a function

Memory: 79/128 MB
Runtime: 753.15 ms&lt;/PRE&gt;&lt;P&gt;and here is the code:&lt;/P&gt;&lt;P&gt;const hubspot = require('@hubspot/api-client');&lt;/P&gt;&lt;P&gt;exports.main = async (event, callback) =&amp;gt; {&lt;BR /&gt;const hubspotClient = new hubspot.Client({ accessToken: process.env.HSAPISara });&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt;// Retrieve the deal ID from the workflow event&lt;BR /&gt;const dealId = event.object.objectId;&lt;/P&gt;&lt;P&gt;// Get associated line items&lt;BR /&gt;const associationsResponse = await hubspotClient.crm.associations.getAll("deal", dealId, "line_item");&lt;/P&gt;&lt;P&gt;if (!associationsResponse || !associationsResponse.results) {&lt;BR /&gt;throw new Error("No associated line items found.");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const lineItemIds = associationsResponse.results.map(association =&amp;gt; association.id);&lt;/P&gt;&lt;P&gt;// Fetch line item details&lt;BR /&gt;const lineItemPromises = lineItemIds.map(async lineItemId =&amp;gt; {&lt;BR /&gt;const lineItemResponse = await hubspotClient.crm.lineItems.basicApi.getById(lineItemId, ["name"]);&lt;BR /&gt;&lt;BR /&gt;if (!lineItemResponse || !lineItemResponse.body || !lineItemResponse.body.properties) {&lt;BR /&gt;throw new Error(`Line item with ID ${lineItemId} is missing properties.`);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;return lineItemResponse.body.properties.name;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const lineItemNames = await Promise.all(lineItemPromises);&lt;/P&gt;&lt;P&gt;// Return the line item names&lt;BR /&gt;callback(null, {&lt;BR /&gt;outputFields: {&lt;BR /&gt;line_items: lineItemNames.join(", ")&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;} catch (error) {&lt;BR /&gt;console.error("Error in workflow execution:", error.message);&lt;BR /&gt;callback(error);&lt;BR /&gt;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;I would really appreciate it if anyone can help me with this.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 10:28:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-making-custom-code-workflow/m-p/1097292#M79662</guid>
      <dc:creator>sflht</dc:creator>
      <dc:date>2025-01-21T10:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with making custom code workflow</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-making-custom-code-workflow/m-p/1097522#M79674</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/886258"&gt;@sflht&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for your question. Have you tried using to get your associations:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;deals.associationsApi.getAll()&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Jaycee&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 16:24:03 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-making-custom-code-workflow/m-p/1097522#M79674</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2025-01-21T16:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with making custom code workflow</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-making-custom-code-workflow/m-p/1098563#M79778</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;&amp;nbsp;Thanks for the help.&amp;nbsp;&lt;BR /&gt;Yes I still get the error:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;2025-01-23T14:34:34.435Z	ERROR	Error in workflow execution: Cannot read properties of undefined (reading 'getAll')

Memory: 79/128 MB
Runtime: 1076.16 ms&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 14:38:08 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-making-custom-code-workflow/m-p/1098563#M79778</guid>
      <dc:creator>sflht</dc:creator>
      <dc:date>2025-01-23T14:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with making custom code workflow</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-making-custom-code-workflow/m-p/1132229#M81434</link>
      <description>&lt;P&gt;The other thing to try would be replacing&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;hubspotClient.crm.associations.getAll&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;with&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;hubspotClient.crm.deals.associationsApi.getAll&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Jaycee&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 19:38:55 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-with-making-custom-code-workflow/m-p/1132229#M81434</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2025-04-04T19:38:55Z</dc:date>
    </item>
  </channel>
</rss>

