Skip to content
Automations and review

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.

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.

Pick one mapping. The tracking field stores the HubSpot record ID and stops duplicates. It must be a writable Text field.

HubSpotLightfieldLightfield tracking field
CompanyAccounthubspot_company_id
ContactContacthubspot_contact_id
DealOpportunityhubspot_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.

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.

  1. 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.
  2. 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.
  3. Answer the agent’s questions, then review the fields, the match rule and the permissions.

  4. Grant the permissions when the approval card appears.

  5. Test with your HubSpot test record’s real ID, then run the same payload again with one changed value.

  6. Confirm the first run created one record and the second run updated it.

  7. Activate the automation.

  8. Click Copy webhook URL on the automation’s webhook trigger, or ask the agent for the URL.

Do this part in HubSpot, under Automation → Workflows.

  1. Select Create workflow → From scratch.
  2. Select Skip trigger and choose eligible records, choose the HubSpot record type, and select Save and continue.
  3. Name the workflow Sync [record type] to Lightfield.
  4. Select When an event occurs and add Object created.
  5. Add one Property value changed event for each property you sync.
  6. 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.
  7. Select Yes, re-enroll every time the trigger occurs, then save the trigger.
  1. Select + in the workflow, then Custom code. Keep Node.js as the language.
  2. Add a secret named LIGHTFIELD_WEBHOOK_URL with the Lightfield webhook URL as its value.
  3. 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, domain and industry for companies; firstname, lastname, email and phone for contacts; and dealname, amount and dealstage for deals.
  4. 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: {} });
};
  1. In the Custom code action, select Test action, choose your test record, and run it.
  2. In Lightfield, check the record type, the copied fields and the HubSpot ID.
  3. Change one synced property on the HubSpot record and run Test action again.
  4. Confirm Lightfield updated the same record without creating a duplicate.
  5. Turn on the HubSpot workflow.
  6. 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.

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.

If a duplicate appears or the wrong record changes, turn off the HubSpot workflow before you test again.

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.

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.

The property is missing from Properties to include in code or from the automation’s mapping. Add it to both.

Event triggers don’t include changes from before the workflow was on. Enroll those records by hand.

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.