Contact association with a custom Object

SErrigo
参加者

Hi,

I'm building for my customer automation that creates a record in a custom object. This custom object has a foreign key value with a contact username. When my customer click on the username, he would like to find the association with the Contacts automatically. Can you please help me on defining which Endpoint should I use to create this association?

With some examples

Thank you in advance

 

SErrigo_0-1676026584519.png

SErrigo_1-1676026778299.png

 

 

0 いいね!
1件の承認済みベストアンサー
Jaycee_Lewis
解決策
ソートリーダー

Hey, @SErrigo 👋 Here's what you'll need to get started building.

  • Query this endpoint, Retrieve association types, to get the association type IDs from your Custom Object to the Contacts object. Here's my example using my custom object Boat:
    GET /crm/v4/associations/boat/contacts/labels​
    {
        "results": [
            {
                "category": "USER_DEFINED",
                "typeId": 17,
                "label": "tacos"
            },
            {
                "category": "USER_DEFINED",
                "typeId": 22,
                "label": "Hamburger"
            },
            {
                "category": "USER_DEFINED",
                "typeId": 20,
                "label": "Pizza"
            },
            {
                "category": "USER_DEFINED",
                "typeId": 15,
                "label": null
            }
        ]
    }
  • Then we can use the Associate an object with another object endpoint to create the association. Documentation — Associate records and set an association label.
    My example:
    curl --request PUT \
      --url https://api.hubapi.com/crm/v3/objects/2-7913954/4367801976/associations/0-1/901/17 \
      --header 'authorization: Bearer YOUR_ACCESS_TOKEN'​
    HTTP 200
    
    {
      "id": "4367801976",
      "properties": {
        "hs_createdate": "2022-12-07T22:51:37.024Z",
        "hs_lastmodifieddate": "2022-12-07T22:51:37.024Z",
        "hs_object_id": "4367801976"
      },
      "createdAt": "2022-12-07T22:51:37.024Z",
      "updatedAt": "2022-12-07T22:51:37.024Z",
      "archived": false,
      "associations": {
        "contacts": {
          "results": [
            {
              "id": "501",
              "type": "boat_to_contact"
            },
            {
              "id": "601",
              "type": "boat_to_contact"
            },
            {
              "id": "901",
              "type": "boat_to_contact"
            },
            {
              "id": "901",
              "type": "tacos"
            }
          ]
        }
      }
    }

This set the association from Boat > Contact for my contact Bob Belcher (contact ID 901) and used the custom association label I created previously called tacos (I must have needed lunch that day… 🤣)

Have fun building! — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




元の投稿で解決策を見る

3件の返信 3
DStaat
参加者

Hey @SErrigo,

I'm a little late to the party but have you heard of Associ8? It lets you automatically create associations between objects based on parameters you set. There's some documentation showing how it works here.

Let me know if you have any questions! I'd be happy to talk with you about it in more detail.

Best,

-David Staat

0 いいね!
Jaycee_Lewis
解決策
ソートリーダー

Hey, @SErrigo 👋 Here's what you'll need to get started building.

  • Query this endpoint, Retrieve association types, to get the association type IDs from your Custom Object to the Contacts object. Here's my example using my custom object Boat:
    GET /crm/v4/associations/boat/contacts/labels​
    {
        "results": [
            {
                "category": "USER_DEFINED",
                "typeId": 17,
                "label": "tacos"
            },
            {
                "category": "USER_DEFINED",
                "typeId": 22,
                "label": "Hamburger"
            },
            {
                "category": "USER_DEFINED",
                "typeId": 20,
                "label": "Pizza"
            },
            {
                "category": "USER_DEFINED",
                "typeId": 15,
                "label": null
            }
        ]
    }
  • Then we can use the Associate an object with another object endpoint to create the association. Documentation — Associate records and set an association label.
    My example:
    curl --request PUT \
      --url https://api.hubapi.com/crm/v3/objects/2-7913954/4367801976/associations/0-1/901/17 \
      --header 'authorization: Bearer YOUR_ACCESS_TOKEN'​
    HTTP 200
    
    {
      "id": "4367801976",
      "properties": {
        "hs_createdate": "2022-12-07T22:51:37.024Z",
        "hs_lastmodifieddate": "2022-12-07T22:51:37.024Z",
        "hs_object_id": "4367801976"
      },
      "createdAt": "2022-12-07T22:51:37.024Z",
      "updatedAt": "2022-12-07T22:51:37.024Z",
      "archived": false,
      "associations": {
        "contacts": {
          "results": [
            {
              "id": "501",
              "type": "boat_to_contact"
            },
            {
              "id": "601",
              "type": "boat_to_contact"
            },
            {
              "id": "901",
              "type": "boat_to_contact"
            },
            {
              "id": "901",
              "type": "tacos"
            }
          ]
        }
      }
    }

This set the association from Boat > Contact for my contact Bob Belcher (contact ID 901) and used the custom association label I created previously called tacos (I must have needed lunch that day… 🤣)

Have fun building! — Jaycee





loop


Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.

Learn More




SErrigo
参加者

Thank you so much @Jaycee_Lewis this is exactly what I was looking for.

I hope you eat something after this😜