HubSpot sync
Set up a one-way sync that creates or updates Lightfield records whenever a HubSpot record is created or changes.
Available on Pro, Growth and Enterprise
When a HubSpot record is created, or a property you sync changes, Lightfield creates or updates the matching record. The sync runs one way, from HubSpot to Lightfield, through one HubSpot workflow and one Lightfield automation for each record type you sync.
The sync matches records by HubSpot ID, copies only the fields you choose, and creates or updates records. It doesn’t match by name, delete or merge records, copy blank values, or send changes back to HubSpot.
Who can use it
Section titled “Who can use it”You need:
- a Lightfield plan with automations (Pro, Growth and Enterprise), and an owner or admin role, since only they can create automations
- access to HubSpot workflows on HubSpot Data Hub Professional or Enterprise, which the Custom code action requires
- one HubSpot record you can safely test with
Earlier plans can differ. Check your workspace’s available features.
Choose what to sync
Section titled “Choose what to sync”Pick one mapping. The tracking field stores the HubSpot record ID and stops duplicates. It must be a writable Text field.
| HubSpot | Lightfield | Lightfield tracking field |
|---|---|---|
| Company | Account | hubspot_company_id |
| Contact | Contact | hubspot_contact_id |
| Deal | Opportunity | hubspot_deal_id |
Then write down the fields to copy as pairs: [HubSpot property] → [Lightfield field]. Start with HubSpot Company → Lightfield Account, copying only the company name, domain and industry. A small first mapping is easy to check.
Set up Lightfield
Section titled “Set up Lightfield”Do this part in chat with the agent. Tests create or update real records, so use the test record you chose. Keep the webhook URL private: anyone who has it can start runs. Store it as a HubSpot secret.
-
Replace the bracketed text in this prompt and send it:
I am setting up a one-way sync from HubSpot [record type] to Lightfield [record type].Inspect the Lightfield [record type] fields. Confirm that:- [Lightfield field] exists and is writable.- [Lightfield field] exists and is writable.- [tracking field] exists as a writable Text field.If a field is missing, create it if you can. If you cannot, tell me what I need to add and stop.Do not create or update CRM records yet. -
Once the agent confirms every field exists with the right type, send:
Create a draft automation named:HubSpot → Lightfield | [HubSpot record type] to [Lightfield record type]Use an inbound webhook with this payload:{"source": "hubspot","object": {"type": "[HubSpot record type]","id": "[HubSpot record ID]","properties": {}}}For each run:1. Require source to equal "hubspot" and object.id to be present.2. Find the Lightfield [record type] whose [tracking field] exactly equals object.id.3. If there is no match, create one record and save object.id in [tracking field].4. If there is one match, update it.5. If there is more than one match, stop without changing a record.6. Copy only these non-blank properties:- object.properties.[HubSpot property] → [Lightfield field]- object.properties.[HubSpot property] → [Lightfield field]7. Never match by name. Never delete or merge records.Use the correct Lightfield field keys and value types. Propose only the required permissions. Show me the draft before activating it. -
Answer the agent’s questions, then review the fields, the match rule and the permissions.
-
Grant the permissions when the approval card appears.
-
Test with your HubSpot test record’s real ID, then run the same payload again with one changed value.
-
Confirm the first run created one record and the second run updated it.
-
Activate the automation.
-
Click Copy webhook URL on the automation’s webhook trigger, or ask the agent for the URL.
Create the HubSpot workflow
Section titled “Create the HubSpot workflow”Do this part in HubSpot, under Automation → Workflows.
- Select Create workflow → From scratch.
- Select Skip trigger and choose eligible records, choose the HubSpot record type, and select Save and continue.
- Name the workflow
Sync [record type] to Lightfield. - Select When an event occurs and add Object created.
- Add one Property value changed event for each property you sync.
- Under AND only enroll records that also meet these filters, define which records may sync. HubSpot requires this filter for Object created, and joins the events with OR.
- Select Yes, re-enroll every time the trigger occurs, then save the trigger.
Add the Custom code action
Section titled “Add the Custom code action”- Select + in the workflow, then Custom code. Keep Node.js as the language.
- Add a secret named
LIGHTFIELD_WEBHOOK_URLwith the Lightfield webhook URL as its value. - Under Properties to include in code, add only the properties you sync, each named by the HubSpot property’s internal name. Common ones are
name,domainandindustryfor companies;firstname,lastname,emailandphonefor contacts; anddealname,amountanddealstagefor deals. - Paste this code into the action and save it:
const axios = require("axios");
exports.main = async (event, callback) => { if (!process.env.LIGHTFIELD_WEBHOOK_URL) { throw new Error("LIGHTFIELD_WEBHOOK_URL is missing."); }
await axios.post( process.env.LIGHTFIELD_WEBHOOK_URL, { source: "hubspot", object: { type: String(event.object.objectType), id: String(event.object.objectId), properties: event.inputFields, }, }, { headers: { "Content-Type": "application/json" }, timeout: 15000, }, );
callback({ outputFields: {} });};Test and turn on the sync
Section titled “Test and turn on the sync”- In the Custom code action, select Test action, choose your test record, and run it.
- In Lightfield, check the record type, the copied fields and the HubSpot ID.
- Change one synced property on the HubSpot record and run Test action again.
- Confirm Lightfield updated the same record without creating a duplicate.
- Turn on the HubSpot workflow.
- Create or update one real record and confirm it syncs.
The sync is ready when your test record was created once and updated once, and one real record synced.
Sync records that already exist
Section titled “Sync records that already exist”Event triggers only pick up changes made after the workflow is turned on. To sync existing records, enroll them in the HubSpot workflow by hand. Start with a small group.
Troubleshooting
Section titled “Troubleshooting”If a duplicate appears or the wrong record changes, turn off the HubSpot workflow before you test again.
No Lightfield run appears
Section titled “No Lightfield run appears”Check that the automation shows Active, then compare its current webhook URL with the HubSpot secret. If either is wrong, correct it and test again.
HubSpot doesn’t run after a property edit
Section titled “HubSpot doesn’t run after a property edit”The workflow has no Property value changed event for that property, or re-enrollment is off. Add the event, or turn on re-enrollment.
A duplicate record appears
Section titled “A duplicate record appears”Turn off the HubSpot workflow, then ask the agent to inspect the tracking-field rule and the duplicate records. Confirm that the incoming HubSpot ID matches the writable Text tracking field before testing again.
A field doesn’t copy
Section titled “A field doesn’t copy”The property is missing from Properties to include in code or from the automation’s mapping. Add it to both.
Existing records didn’t sync
Section titled “Existing records didn’t sync”Event triggers don’t include changes from before the workflow was on. Enroll those records by hand.
Common questions
Section titled “Common questions”Does the HubSpot sync send changes back to HubSpot? No. The sync runs one way, from HubSpot to Lightfield. Changes you make in Lightfield stay in Lightfield.
How do I sync HubSpot records that already exist? Enroll them in the HubSpot workflow by hand, starting with a small group. Event triggers only see changes made after the workflow is on.
Why is the HubSpot sync creating duplicates?
Usually the tracking field isn’t matching. Turn off the HubSpot workflow, then ask the agent to check that the automation finds records by the tracking field, such as hubspot_company_id, and that it’s a writable Text field.