Associations are used in HubSpot to define a relationship between objects and activities. There could be records that exist in objects that ideally have a relation between them, such as Contact to Company, Contact to Deal, Company to Deal, etc. It is essential to have these properly defined in order to maintain your data and relationships as intended. In this blog post, we will demonstrate how to use KingswaySoft components to easily create and maintain HubSpot Associations. For this demonstration, we will be using the Deal to Contacts Association. In HubSpot, Deals represent transactions with contacts or companies. The Deals endpoints allow you to create and manage deal records, as well as to sync deal data between HubSpot and other systems. Contacts store information about the individual people who interact with your business. The contacts endpoints allow you to create and manage contact records in your HubSpot account, as well as to sync contact data between HubSpot and other systems.
Below are the components that we will primarily use in this demonstration:
- HubSpot Destination component
- Premium Derived Column component (Can also be substituted with the out-of-the -box derived column component.)
Creating a HubSpot Association
Let's start by having a look at a deal record that we will be working with. As shown below, the deal Fortest_11 does not currently have any Contacts associated with it. Our objective is to create an association record for it.
Now, to create an association between two objects, we will be using the HubSpot Destination Component drag-and-drop the component, then configure the connection manager, and in the Destination component, choose the object CRM Association v4. If you wish to know more about different authentication options for Hubspot using our connection manager, please refer to our Online Help Manual link here.
Once the general page has been configured, navigate to the columns page, where you will need to map all the specified fields to create the association, as shown below.
And so, it would be a good idea to have that information beforehand. You can find the information by reading from the HubSpot Source Component. In this case, we read the Deal endpoint and get the dealid.
We will also need the ID of the object with which you are trying to create an association. In this case, since we are building a Deal and Contact association, we will need the ID for the Contact object. And this can be done in a similar manner as above, by querying the Contact object using the HubSpot Source Component.
Once we have the data ready with us, we can map the fields accordingly.
- ObjectId is the ID of the object we create the association with. In this case, it will be the dealid.
- ToObjectId is the ID of the object we are linking to the initial object, which will be the contactid.
- ObjectType and ToObjectType are the Types for the objects we are linking. So it would be deal and contact.
- AssociationCategory will be mapped whether the association type was created by HubSpot (HUBSPOT_DEFINED) or by a user (USER_DEFINED). In this case it is HUBSPOT_DEFINED.
- AssociationTypeId is the numeric ID for that association type. This is used to set a label when associating records. You can find which Association Type ID to use in the Hubspot CRM API Documentation (link here)
In this example, we are using a Premium Derived Column to simulate passing in these input values. However, in a real-world scenario, you will be passing these values from a Source Object.
And once all the fields are mapped we can execute the package. Once it runs successfully, you can see that the associations are created by navigating to the HubSpot UI.
Now, let's see how you can read back these associations as a validation.
Retrieving a HubSpot Association
Using the HubSpot Source Component, you can read the CRM Association v4 Object. Then provide the proper filter parameters.
- ObjectType is the type of the object for which we are providing the ID.
- ToObjectType is the type for the object that we are looking for.
- ObjectId is the ID of the object.
Notes: You are able to set a Primary association by adjusting the AssociationTypeId Values. For example, if you are creating an association between Company to Contact, normally the Association Type ID would be 280; however, if the association is a Primary association, you can use 2. By entering 2, it will allow the association to be set as the Primary.
Conclusion
By using KingswaySoft, you can easily create associations as required between HubSpot objects in an effective manner to keep your data and relationships in order.
We hope this has helped!