CMS Development

AKempen
Participant

CRM Extension Card: How to retrieve associatedCompanyId from Record type Deals

LS,

 

We are building a CRM extension card called "Pricing", we want to target record type Deals. Within this card we want to show a subscription linked to this deal on our platform, to do so we need to know for which company/contact this deal is made so we can link it to our customer.

How can we retrieve (e.g.) CompanyId from the Deal record, as I do not see any linked elements in "PROPERTIES SENT FROM HUBSPOT".

PS. we only want to show this card on the Deal record type.

 

I hope you can help me with this, would be awesome!

0 Upvotes
2 Replies 2
nikodev
Top Contributor | Elite Partner
Top Contributor | Elite Partner

CRM Extension Card: How to retrieve associatedCompanyId from Record type Deals

Hey there @AKempen - I don't know how you'd go about retrieving any associated Company IDs without explicit use of the HubSpot APIs. I'd recommend sending the hs_object_id of the Deal from your React component, to your serverless function via the "runServerlessFunction" argument of the hubspot.extend function The serverless function code will be in your app.functions folder. In your serverless function code, you could use either the search Companies endpoint, like so (using a request in the docs as a template, hence the use of curl): 

curl https://api.hubapi.com/crm/v3/objects/companies/search \
  --request POST \          
  --header "Content-Type: application/json" \
  --data '{
    "filters": [
      {
        "propertyName": "associations.deal",
        "operator": "EQ",
        "value": `${dealObjectId}`
      }
    ]
  }'


 Or, more in line with recent updates: association labels and the ability to associate multiple companies with a deal -> you'd use the V4 Associations endpoint: 

curl --request POST \
  --url https://api.hubapi.com/crm/v4/associations/deal/company/batch/read \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'content-type: application/json' \
  --data '{
  "inputs": [
    {
      "id": `${dealObjectId}`,
    }
  ]
}'

 
I know that was a mouthful. All of this assumes you have fair familiarity with React based CRM Cards - I'd recommend taking a look at HubSpot's github example here for further guidance.

Thanks for the tag @Jaycee_Lewis.  

A8 Labs

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

CRM Extension Card: How to retrieve associatedCompanyId from Record type Deals

Hi, @AKempen 👋 Thanks for the interesting question. I'd like to invite some of our community members to the converstaion. Hey @louischausse @himanshurauthan @nikodev have you worked on a project like this recently?

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes