# Issues with making custom code workflow

**URL:** <https://community.hubspot.com/t/issues-with-making-custom-code-workflow/124428>\
**Category:** APIs & Integrations\
**Tags:** starter\
**Created:** [January 21, 2025, 10:28am UTC](https://community.hubspot.com/t/issues-with-making-custom-code-workflow/124428 "2025-01-21T10:28:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sflht](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@sflht](https://community.hubspot.com/u/sflht)\
**Post date:** [January 21, 2025, 10:28am UTC](https://community.hubspot.com/t/issues-with-making-custom-code-workflow/124428/1 "2025-01-21T10:28:42Z")

</div>

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.  
this is the error I’m getting:

```auto
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

```

and here is the code:

const hubspot = require(‘@hubspot/api-client’);

exports.main = async (event, callback) =\> {  
const hubspotClient = new hubspot.Client({ accessToken: process.env.HSAPISara });

try {  
// Retrieve the deal ID from the workflow event  
const dealId = event.object.objectId;

// Get associated line items  
const associationsResponse = await hubspotClient.crm.associations.getAll(“deal”, dealId, “line\_item”);

if (!associationsResponse || !associationsResponse.results) {  
throw new Error(“No associated line items found.”);  
}

const lineItemIds = associationsResponse.results.map(association =\> association.id);

// Fetch line item details  
const lineItemPromises = lineItemIds.map(async lineItemId =\> {  
const lineItemResponse = await hubspotClient.crm.lineItems.basicApi.getById(lineItemId, [“name”]);  
if (!lineItemResponse || !lineItemResponse.body || !lineItemResponse.body.properties) {  
throw new Error(`Line item with ID ${lineItemId} is missing properties.`);  
}  
return lineItemResponse.body.properties.name;  
});

const lineItemNames = await Promise.all(lineItemPromises);

// Return the line item names  
callback(null, {  
outputFields: {  
line\_items: lineItemNames.join(", ")  
}  
});  
} catch (error) {  
console.error(“Error in workflow execution:”, error.message);  
callback(error);  
}  
};

I would really appreciate it if anyone can help me with this.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [January 21, 2025, 4:24pm UTC](https://community.hubspot.com/t/issues-with-making-custom-code-workflow/124428/2 "2025-01-21T16:24:03Z")

</div>

Hey, @sflht 👋 Thanks for your question. Have you tried using to get your associations:

`deals.associationsApi.getAll()`

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [April 4, 2025, 7:38pm UTC](https://community.hubspot.com/t/issues-with-making-custom-code-workflow/124428/3 "2025-04-04T19:38:55Z")

</div>

The other thing to try would be replacing

`hubspotClient.crm.associations.getAll`

with

`hubspotClient.crm.deals.associationsApi.getAll`

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![sflht](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@sflht](https://community.hubspot.com/u/sflht)\
**Post date:** [January 23, 2025, 2:38pm UTC](https://community.hubspot.com/t/issues-with-making-custom-code-workflow/124428/4 "2025-01-23T14:38:08Z")

</div>

Hey [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) Thanks for the help.  
Yes I still get the error:

```auto
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

```
