Get Associated Object Properties in Custom Code Action

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:

@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!

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.

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

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;	
})

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 :slightly_smiling_face:

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.

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

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.

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

Same custom code action.

@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.