Implementing custom master-detail (Parent-child) relationships and rollup summary fields in HubSpot
HubSpot’s custom objects functionality allows you to create master-detail relationships between custom objects, enabling you to build powerful data structures and generate rollup summary fields.
In this example, we’ve created custom system architecture within our Sales Hub to track expenses against a Deal. Our object, ‘Expense Report’ works with our Hubspot Deals to track Expenses against deals in HubSpot. Within the ‘Expense Report’ Object, we have a secondary object called ‘Expense Entries’ that will handle each related entry related to the Expenses.
Defining the Master-Detail relationship
Create Custom Objects: Start by creating the custom objects that will participate in the master-detail relationship, defining the properties for each object as needed.
Define Associations: Within the settings for the custom object designated as the “detail” object (child), you’ll need to define the association with the “master” object (parent).
Specify Association Type: When creating the association, ensure you select the appropriate association type that establishes the master-detail relationship. In HubSpot, you’ll associate the child object to the parent object directly, typically indicating that one parent can have multiple children records.
Creating Rollup Summary Fields
Navigate to Properties: In your HubSpot account, go to Settings > Properties.
Select Master Object: Choose the master object (the one where the rollup summary field will display) from the Select an object: dropdown menu.
Create Property: Click Create Property.
Select Rollup Field Type: In the property creation flow, select Rollup as the field type.
Configuring Rollup Details
Rollup type: Choose the aggregation type (e.g., Min, Max, Count, Sum, Average) you need for your rollup summary.
Associated object and property: Specify the associated (child) object and the property within that object that you want to roll up.
Conditional filtering (optional): Apply conditions if you want the rollup calculation to be based on specific criteria within the associated records.
Example: Master-Detail and rollup summary for expenses
Imagine you have a custom object called “Expense Report” and another custom object called “Expense Entry.” You want to roll up the total amount of all “Expense Entries” to the associated “Expense Report”.
Create custom objects:
Expense Report: Create the “Expense Report” custom object with properties like “Report Name”, “Date”, etc.
Expense Entry: Create the “Expense Entry” custom object with properties like “Item”, “Amount”, “Category”, etc.
Define association: Associate “Expense Entry” to “Expense Report,” making “Expense Report” the parent.
Create rollup summary field
- Go to “Expense Report” properties.
- Create a new property.
- Select “Rollup” as the field type.
- Choose “Sum” as the rollup type and select “Expense Entry” as the associated object and “Amount” as the property to sum.
- This setup allows you to automatically calculate the total expense amount on each “Expense Report” based on the associated “Expense Entry” records, providing a clear overview of the overall spending for each report.
