APIs & Integrations

James_Swallow
参加者

Creating An Association In Custom Code Workflow

解決

Hi all.

 

Can some kind person point out what I'm doing wrong with the code below on my custom workflow? Everything else in my code works, but once I try an update, I'm hit with all sorts of erros no matter how much I tweak.

 

hubspotClient.crm.objects.associationsApi.create({



"fromObjectId": contact_id,
"toObjectId": found_company_id,
"category": "HUBSPOT_DEFINED",
"definitionId": 1,
"associationType": "contact_to_company"
}
)

 

Many thanks in advance

 

 

0 いいね!
1件の承認済みベストアンサー
James_Swallow
解決策
参加者

Creating An Association In Custom Code Workflow

解決

Hi Lee.

 

Thanks loads for the help. Between your feedback and a colleague I got there. It’s:

hubspotClient.crm.objects.associationsApi.create("CONTACT",contact_id,"COMPANY",found_company_id,"contact_to_company",1)
  
}

 

The main reason I was having issues was due to the fact that the you must explicitly state what the object type is before providing its ID number. I’d been trying this and it was still failing until I realised it’s case sensitive and must be in capitals, so ‘CONTACT’ and ‘COMPANY’ work.

 

Thanks for pointing me in the right direction Lee

元の投稿で解決策を見る

0 いいね!
3件の返信
AStoyanov
参加者

Creating An Association In Custom Code Workflow

解決

I know this thread may be old, but I was able to make it work by using only this syntax:

hubspotClient.crm.objects.associationsApi.create("contacts",contactId,"companies", companyId, 'contact_to_company' )

I thought for both companies and contacts the default object type is "contact" and "company" but it depends on how exactly your objects are named. In my case my objecst are "companies" and "contacts". 

Hope that helps!

0 いいね!
James_Swallow
解決策
参加者

Creating An Association In Custom Code Workflow

解決

Hi Lee.

 

Thanks loads for the help. Between your feedback and a colleague I got there. It’s:

hubspotClient.crm.objects.associationsApi.create("CONTACT",contact_id,"COMPANY",found_company_id,"contact_to_company",1)
  
}

 

The main reason I was having issues was due to the fact that the you must explicitly state what the object type is before providing its ID number. I’d been trying this and it was still failing until I realised it’s case sensitive and must be in capitals, so ‘CONTACT’ and ‘COMPANY’ work.

 

Thanks for pointing me in the right direction Lee

0 いいね!
LeeBartelme
HubSpot Employee
HubSpot Employee

Creating An Association In Custom Code Workflow

解決

Pretty sure you want this:

 

hubspotClient.crm.objects.associationsApi.create(contact_id,found_company_id,"HUBSPOT_DEFINED",1,"contact_to_company")

 

 The function expects individual arguments, not an object. See example documentation.