Sub topic 2
Linking Activities to the Right Records
This chapter assumes you understand a B2B sales process (leads, qualification, closing), can read a CRM screen, and can read JSON. A CRM is a customer database that tracks sales. A record is one item in it, such as a deal or a contact. An activity is a logged call, email, meeting, note, or task. Salesforce calls deals "Opportunities" and HubSpot calls them "Deals."
Linking activities to the right records
Each activity should point to the deal it advances and to the people who took part. Salesforce stores the related deal in WhatId and a person in WhoId. HubSpot uses associations, which are explicit links between an activity and a deal, contact, or company.
A common error is logging a call only on the contact. The deal timeline stays empty, and any report that counts activity per deal misses the call.
Keeping deal stage, amount and close date current
Update the deal when the facts change, not at quarter end. Stage, amount, and close date drive forecasts, so a stale close date moves a deal out of the period it belongs to.
import os
import requests
deal_id = os.environ["DEAL_ID"]
url = f"https://api.hubapi.com/crm/v3/objects/deals/{deal_id}"
headers = {
"Authorization": f"Bearer {os.environ['HUBSPOT_TOKEN']}",
"Content-Type": "application/json",
}
body = {"properties": {"dealstage": "contractsent", "closedate": "2026-12-31T00:00:00Z"}}
resp = requests.patch(url, headers=headers, json=body, timeout=30)
resp.raise_for_status()
print(resp.json()["properties"]["dealstage"])Stage values such as contractsent are internal IDs. Check them in your pipeline settings first, because customized pipelines use different IDs.
Logging a call, meeting, note or task by hand
Open the deal, choose the activity type, and fill in the date, the associated contacts, and a short summary. Log within 24 hours while the details are fresh. A task is an open to-do with a due date. A note is free text with no due date.
Writing useful activity records: outcome and next step
Every record should state what happened and what happens next. "Call with Dana, went fine" tells a teammate nothing. "Dana confirmed the CFO owns the budget. Next step: send pricing by Friday, Dec 4" lets someone act without asking you.
Exercise
A buyer's call is logged only on her Contact record. Which link is missing, and why does it matter for reporting?
Show answer
The link to the deal (WhatId in Salesforce, or the deal association in HubSpot). Pipeline reports count activity per deal, so this call is missing from the deal's activity count and timeline.