> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unifygtm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How bidirectional syncs work

> An in-depth explanation of how syncs work between Salesforce and Unify.

## Overview

Unify can create and update Salesforce records in response to Play runs and
Sequence enrollments. This page summarizes the rules used to determine when and
how to create or update records in Salesforce.

## Sync timing

Salesforce read syncs are scheduled approximately every 15 minutes. When a large
number of records change quickly in Salesforce, the next scheduled sync may take
longer to complete, which can temporarily delay the appearance of new or updated
records in Unify.

When a Salesforce field mapping changes, Unify starts a background job to
reprocess all records for the affected object. This does not interfere with the
regular sync schedule, but it does mean that field mapping updates can take some
time to be fully reflected in Unify.

## Overwriting data

Unify takes a very conservative approach to overwriting existing Salesforce data
to make data loss impossible. This approach is based around only a few simple
rules:

* **Creating new records:** When Unify is creating a new Salesforce record, it
  will fill in all fields that are enabled for writing in the field mapping or
  default values.

* **Updating existing records:** Unify will inspect whether the field is empty
  or not. If the field is empty, it will be updated with the new value. If the
  field already has a value, it will only be updated if it is a Unify-specific
  field. These fields are prefixed with "Unify" and can be found [here](/reference/integrations/salesforce/field-mappings#available-fields).

These rules apply regardless of how the record was originally created (e.g., by
Unify or externally). If you're looking for more fine-grained control, you can
also limit the permissions granted to the Unify integration user in Salesforce.

## Duplicate prevention

Duplicates are strictly prevented within Unify. When creating new Salesforce
records, Unify will only ever create one record. If there is already an existing
Salesforce record of the same type, Unify will always update it rather than
creating a new one.

However, duplicates are a common problem in Salesforce and may already exist in
your Salesforce instance. In addition, users or other integrations may
accidentally create new duplicates over time.

To accommodate this reality, Unify follows specific rules to ensure predictable
behavior when updating duplicated Salesforce records. While Unify cannot
de-duplicate your Salesforce, it will *never* make the problem worse, and in
some situations may be able to help clarify the “source of truth” record.

## Supported objects

<AccordionGroup>
  <Accordion title="Accounts">
    Salesforce accounts are written by Unify whenever a contact is created or
    updated. They are also written if a Salesforce sync action runs within a Play
    that is running on companies.

    If there is an existing account that matches the Unify company being written, it
    will be updated. Matches are determined based on the domain of the company
    website. Domains are normalized, so URLs that redirect to different domains will
    not result in duplicates. If there are no matches, a new account will be
    created.

    If there are multiple accounts that match the Unify company, only one will be
    updated. Specifically, the account that was most recently modified within
    Salesforce will be updated.
  </Accordion>

  <Accordion title="Contacts">
    Salesforce contacts are written by Unify if **Create new records as Contacts & Accounts**
    is selected. In addition, contacts are sometimes created in place of leads if
    the person being written to Salesforce *already exists* as a contact. Unify
    cannot create a lead in this situation due to Salesforce’s
    [contact duplicate rules](https://help.salesforce.com/s/articleView?language=en_US\&id=sf.duplicate_rules_standard_contact_rule.htm\&type=5).

    In both situations, if there is an existing contact that matches the Unify
    person being written, it will be updated. Matches are determined based on email
    address. If there are no matches, a new contact will be created.

    If there are multiple contacts that match the Unify person, only one will be
    updated. Specifically, the contact that was most recently modified within
    Salesforce is the one that will be updated.
  </Accordion>

  <Accordion title="Leads">
    Salesforce leads are written by Unify when **Create new records as Leads** is
    selected.

    If there is an existing lead that matches the Unify person being written, it
    will be updated. Matches are determined based on email address. If there are no
    matches, a new lead will be created.

    If there are multiple leads that match the Unify person, only one will be
    updated. Specifically, the lead that was most recently modified within
    Salesforce is the one that will be updated.
  </Accordion>

  <Accordion title="Email messages">
    Unify writes to the email message object in Salesforce, which is the recommended
    approach for syncing email data to Salesforce. To write records of this object
    type, the *Enhanced Email* feature must be enabled in Salesforce. This is
    typically enabled by default.

    Unify does not update existing email messages in Salesforce. Only emails sent
    through Unify or received in response to those emails will be written to
    Salesforce. Unify uses the standard **Universal Message ID** to deduplicate
    email messages if they are simultaneously being written by another integration.

    Email messages are written to Salesforce for emails sent as a part of Unify
    Sequences and for replies to those emails. The corresponding person must already
    exist in Salesforce as a contact or lead, or a Play action must sync the person
    to Salesforce before the email activity is written.

    Email messages can include mapped email activity fields such as subject,
    content, sent time, bounce status, click count, open timestamps, spam status,
    opt-out status, the enrolling Play, and Sequence name. These values are written
    only when the relevant event exists and the mapped Salesforce field is writable
    by the integration user.
  </Accordion>

  <Accordion title="Tasks">
    Unify writes eligible Unify tasks to the Salesforce Task object. This
    includes ready or completed non-email tasks, such as phone-call and
    action-item tasks, and completed email or reply tasks. Unify does not write
    email tasks to Salesforce before they are complete because email sending is
    controlled in Unify.

    Salesforce tasks are related to the corresponding Salesforce contact or
    lead. If the person does not already exist in Salesforce, Unify must sync
    the person to Salesforce before the task can be written. When there is an
    associated company and the person is a contact, Unify can also relate the
    task to the Salesforce account. When the person is a lead, Salesforce does
    not support the same account relationship on the task.

    Task sync uses Unify's standard Salesforce Task mapping rather than the
    company, person, or email message field mapping tables. Unify writes values
    such as subject, description, status, priority, task subtype, due date,
    owner, contact/lead relationship, and account relationship when available.
    When a task is deleted in Unify, Unify deletes the matching Salesforce task.

    Salesforce-to-Unify task sync is limited to completion updates. When a
    non-email Salesforce task that was written by Unify is marked **Completed**
    in Salesforce, Unify marks the corresponding task complete in Unify.

    Completed Salesforce phone-call tasks created by supported dialer
    integrations can also complete the matching open Unify phone-call task when
    Unify can identify a single matching task for the same person. Email tasks
    are excluded from this completion sync.
  </Accordion>

  <Accordion title="Opportunities">
    Salesforce opportunities are read into Unify as opportunity records. They can be
    associated with companies and people when the Salesforce opportunity has the
    corresponding account or contact relationship.

    Opportunity data is primarily CRM-owned. Unify uses it for record context,
    filters, and exclusions, such as excluding companies with open
    opportunities from outbound Plays. Unify does not create or update Salesforce
    opportunities itself.
  </Accordion>
</AccordionGroup>
