[object Object]

The first ServiceNow-Salesforce sync I ever inherited was bidirectional, eager, and would update a record in a loop until somebody noticed the API call counter spiking. Bidirectional sync is the single most over-engineered integration pattern on either platform. Most use cases need much less.

Define authority before you write code

For every field that flows in either direction, name the system of record. There are exactly four valid patterns:

  • Salesforce-authoritative — Salesforce writes, ServiceNow reads
  • ServiceNow-authoritative — ServiceNow writes, Salesforce reads
  • Time-windowed authority — one system owns until a state transition
  • Conflict-resolution function — both can write, deterministic merge rule

If you cannot articulate the pattern per field, you are not ready to build.

The ping-pong trap

Both systems have triggers. ServiceNow updates Salesforce, which fires the Salesforce trigger, which updates ServiceNow, which fires the ServiceNow Business Rule. Write a last_modified_source field on both sides and ignore inbound updates from your own system within a short window:

// Business Rule: before update
if (current.u_last_modified_source == 'salesforce' &&
    current.u_last_modified_source.changesFrom('servicenow')) {
  // bounce-back, suppress
  current.setAbortAction(true);
}

Use idempotent external IDs

Every synced record has an external ID on both sides. Salesforce uses External ID fields with upsert semantics. Use ServiceNow’s correlation_id and correlation_display. Never key on email or name.

Backpressure with a queue table

Direct Business-Rule-to-API calls collapse during outages. Use a queue table:

Table: u_sf_sync_queue
Columns:
  operation (create | update | delete)
  source_table
  source_sys_id
  payload (json)
  attempts
  last_error
  next_retry_at

A scheduled job drains the queue with retry and a circuit breaker on the Salesforce endpoint.

Field mapping lives in data, not code

Hardcoding field maps in Script Includes makes every change a deploy. Build a u_sf_field_map table that the sync engine reads at runtime. Business analysts can change mappings without dev work.

Watch the API governor

Salesforce daily API limits will bite you the first week of bulk migration. Allocate 30% headroom. Use Bulk API for any operation touching more than 200 records.

What to do this week

Audit your existing sync. Identify any field that does not have a documented authority. Pick the worst offender and write the authority decision in an ADR before the next change. Conflicts will resolve themselves the moment the rule exists.

[object Object]
Share