APIs & Integrations

Sylg
参加者

Create Custom Object Association in Custom code in Workflow

解決

Hey Everyone,

 

I'm building a workflow that will 

 

  1. find the associated company of a workspace (custom object)
  2. look if this company has an associated open deal
  3. If so, associate the workspace to the deal

On paper, this is straight forward but I can't find the function of the nodeJs library to lookup association on a custom object and to create an association on a custom object

 

According to the CRM API v3 docs, it should be 

 

hubspotClient.crm.associationsApi.getAll(objectType, objectId, toObjectType, after, limit);

 to lookup an association but this return 

 

{"errorType":"TypeError","errorMessage":"Cannot read property 'getAll' of undefined","stack":["TypeError: Cannot read property 'getAll' of undefined","    at Object.exports.main

I tried doing the call via HTTP in Postman and the endpoint work.

 

Can someone tell me the function to lookup associated objects and the function to create an association with a custom object, please?

 

Thanks

0 いいね!
1件の承認済みベストアンサー
kierana
解決策
投稿者

Create Custom Object Association in Custom code in Workflow

解決

The documentation is actually incorrect for this - It's always worth using Intellisense in your IDE to get the right methods. Try

hubspotClient.crm.objects.associationsApi.getAll(.....)

元の投稿で解決策を見る

5件の返信
DStaat
参加者

Create Custom Object Association in Custom code in Workflow

解決

Hey @Sylg,

I know this thread is a bit old but have you heard of Associ8? It associates objects (Custom Objects included) via workflow based off criteria you set!

DStaat_0-1693339004798.png


You can check it out on the HubSpot Marketplace here.

If you have any questions, feel free to reach out to me!

Best,

-David Staat

0 いいね!
kierana
解決策
投稿者

Create Custom Object Association in Custom code in Workflow

解決

The documentation is actually incorrect for this - It's always worth using Intellisense in your IDE to get the right methods. Try

hubspotClient.crm.objects.associationsApi.getAll(.....)
NMueller
参加者 | Platinum Partner
参加者 | Platinum Partner

Create Custom Object Association in Custom code in Workflow

解決

Hello, I am in a similar situation as @Sylg. And this solution is not working for me.

I am creating a workflow with custom code actions that needs to look up associations for one custom object to another custom object. 

So I have tested and confirmed this endpoint is working from the docs:

Screen Shot 2022-05-26 at 1.22.05 PM.png

 

And brought the relevant code into the custom code action in my workflow. But I ran into same error as mentioned above.

 

{"errorType":"TypeError","errorMessage":"Cannot read property 'getAll' of undefined","stack":[ ...

 

 

And then I found this thread! So I have updated my script within the custom code action to include hubspotClient.crm.objects.associationsApi.getAll(...), as seen below. 

 

Screen Shot 2022-05-26 at 1.22.35 PM.png

 And now I am running into this:

 

 

ERROR	{
  "statusCode": 500,
  "body": {
    "status": "error",
    "message": "internal error",
    "correlationId": "164444ce-8a12-4bd6-bf03-9538ee174fd9"
  } ...

 

 

At this point, I'm kinda lost! Anybody know how to list associations from custom object to custom object correctly?

0 いいね!
NMueller
参加者 | Platinum Partner
参加者 | Platinum Partner

Create Custom Object Association in Custom code in Workflow

解決

Gah! Just discovered, I need to utilize V4 API documentation as seen here https://developers.hubspot.com/docs/api/crm/associations to get this working. I've updated my custom code in workflow, and it is working now with V4 formatted request: 

 

Screen Shot 2022-05-26 at 2.48.16 PM.png

dennisedson
HubSpot製品開発チーム
HubSpot製品開発チーム

Create Custom Object Association in Custom code in Workflow

解決

@kierana  maybe you have some ideas 😀

0 いいね!