# Get Associated Object Properties in Custom Code Action

**URL:** <https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154>\
**Category:** APIs & Integrations\
**Tags:** workflows\
**Created:** [July 1, 2021, 10:05pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154 "2021-07-01T22:05:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![GregP](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/gregp/32/15342_2.png) [@GregP](https://community.hubspot.com/u/GregP)\
**Post date:** [July 1, 2021, 10:05pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/1 "2021-07-01T22:05:50Z")

</div>

I’m working on a custom code action for a workflow and need to get the value of some properties of some associated custom objects for a deal.  
It seems like I would grab the object id of the associated object with:

`hubspotClient.crm.deals.associationsApi.getAll({deal_id}, {object_type_id})`

then get the properties with something like (?) :

`hubspotClient.crm.objects.basicApi.getById({id}, ['property1', 'property2'])`

I don’t really know how to get the id out of the first one (what does it return?), and I think I’m missing something in the second one. How should this be done, and could it be done with a single request?  
Also, if there is any documentation on this Node.js SDK yet, please point me to it, as I’ve only come across a few code examples, and no real documentation. This is the most I’ve been able to find:

> <https://github.com/HubSpot/hubspot-api-nodejs/blob/302786dbb6d75aa6f127f18740c3218688e9cf36/README.md>

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [July 2, 2021, 3:47pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/2 "2021-07-02T15:47:25Z")

</div>

@PCarlson, @albertomedina , @louischausse any of you able to lend a hand here?

@GregP, I agree that we need to get more documentation on the various libraries. I can say that this is being worked on. Hoping we have more available sooner than later!

---

<div class="post-metadata">

**Author:** ![GregP](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/gregp/32/15342_2.png) [@GregP](https://community.hubspot.com/u/GregP)\
**Post date:** [July 2, 2021, 5:57pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/3 "2021-07-02T17:57:23Z")

</div>

In regard to the first part, it looks like this gives me the object id of the first returned object (we only associate one, so that works for my use):

`results.body.results[0].id`

Having that second “results” feels a bit odd semantically.

Still figuring out the second part.

---

<div class="post-metadata">

**Author:** ![GregP](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/gregp/32/15342_2.png) [@GregP](https://community.hubspot.com/u/GregP)\
**Post date:** [July 2, 2021, 6:25pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/4 "2021-07-02T18:25:04Z")

</div>

Hi everyone! 👋

Just adding a quick update for anyone coming across this thread.

HubSpot has introduced improvements to how data from associated records can be used in custom code workflow actions.

You can now use the workflow data panel to select properties from associated records and pass them directly into your custom code action. Depending on your use case, this may eliminate the need to make separate API calls to retrieve those values.

The original two-step API approach is still useful when you need to dynamically identify associated records.

Also, keep in mind that the API key authentication shown in the older example is no longer supported. Current integrations should use a supported access-token authentication method.

Hope this helps!

* * *

Okay, here’s what I’ve gotten to work:

```lia-code-sample
hubspotClient.crm.deals.associationsApi.getAll({deal_id}, {object_typeid})
.then(function(results){
 {object_id} = results.body.results[0].id;
})
.then(function() {
 return hubspotClient.crm.objects.basicApi.getById({object_typeid}, {object_id}, ['foo']);
})
.then(function(results) {
 foo = results.body.properties.foo;	
})

```

- 

Moderator Note: this post was reviewed for relevancy and optimized for clarity on October 23, 2026. Thank you for your contributions to the HubSpot Community!\*

---

<div class="post-metadata">

**Author:** ![louischausse](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/louischausse/32/18067_2.png) [@louischausse](https://community.hubspot.com/u/louischausse)\
**Post date:** [July 5, 2021, 1:23pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/5 "2021-07-05T13:23:24Z")

</div>

Hi @GregP ,

Have you resolved your problem yourself or you still need help?  
If you have found your answer you should mark this post as resolved. If not, I’d be happy to help 🙂

---

<div class="post-metadata">

**Author:** ![GregP](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/gregp/32/15342_2.png) [@GregP](https://community.hubspot.com/u/GregP)\
**Post date:** [July 5, 2021, 3:08pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/6 "2021-07-05T15:08:37Z")

</div>

I found something that works, but left open as I had also asked if there was a way to do this with a single request. That is still unanswered.

---

<div class="post-metadata">

**Author:** ![louischausse](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/louischausse/32/18067_2.png) [@louischausse](https://community.hubspot.com/u/louischausse)\
**Post date:** [July 5, 2021, 7:49pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/7 "2021-07-05T19:49:03Z")

</div>

ok can you send me a screenshot of the worklow where you run those code snippets please?

---

<div class="post-metadata">

**Author:** ![GregP](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/gregp/32/15342_2.png) [@GregP](https://community.hubspot.com/u/GregP)\
**Post date:** [July 6, 2021, 4:08pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/8 "2021-07-06T16:08:55Z")

</div>

The example code above is way more readable for just this question. It has the call to the deal, to get the id of the associated object, and then a call to the associated object to get it’s properties. The questions is if there is a way to directly get the properties of the associated object, without having to do a separate call to first get the id of the associated object.

---

<div class="post-metadata">

**Author:** ![louischausse](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/louischausse/32/18067_2.png) [@louischausse](https://community.hubspot.com/u/louischausse)\
**Post date:** [July 6, 2021, 4:52pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/9 "2021-07-06T16:52:26Z")

</div>

What I want to know is if you make the calls in the same custom code action or in 2 separate custom code actions

---

<div class="post-metadata">

**Author:** ![GregP](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/gregp/32/15342_2.png) [@GregP](https://community.hubspot.com/u/GregP)\
**Post date:** [July 6, 2021, 5:00pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/10 "2021-07-06T17:00:59Z")

</div>

Same custom code action.

---

<div class="post-metadata">

**Author:** ![louischausse](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/louischausse/32/18067_2.png) [@louischausse](https://community.hubspot.com/u/louischausse)\
**Post date:** [July 12, 2021, 7:26pm UTC](https://community.hubspot.com/t/get-associated-object-properties-in-custom-code-action/40154/11 "2021-07-12T19:26:28Z")

</div>

@GregP Sorry for the delayed answer.

In my opinion you can’t do this in the same call so I think what you did is the best way to do it.

Custom code workflow actions can now receive associated-record properties directly through configured data inputs, without necessarily requiring those two API requests.

_Moderator Note: this post was reviewed for relevancy and optimized for clarity on October 23, 2026. Thank you for your contributions to the HubSpot Community!_
