Back to Articles
Architecture
Base44
Architecture
Data Sync
Best Practices

Data Synchronization Between a Primary Record and Process Records

How to manage data flow between entities in complex Base44 systems

Base4u Solutions5 min read

When building complex systems on Base44, one of the core challenges is managing how data flows between entities.

The Problem

Most systems include:

  • •A primary record (Lead) — the source of truth
  • •Multiple process records — business flows created from it

For example, a lead generates:

  • •A sales process
  • •A service process
  • •A project process

Each evolves independently.

The Real Challenge

The issue begins when the lead continues to receive updates:

  • •Documents are uploaded
  • •Tasks are completed
  • •Data is updated

While multiple processes are already active.

The key question:

Which process should receive the new data?

What Happens Without Proper Design

❌ Syncing to all processes → Leads to data leakage and confusion

❌ Not syncing at all → Creates inconsistencies

❌ Blind overwrites → Destroys manual work done by users

The Solution: Primary Process Sync

1. Identify the Primary Process

javascript
const processes = await Processes.filter(
  { parent_lead_id: lead.id },
  'creation_date',
  1,
  0
)

const primaryProcess = processes[0]

The first created process = the primary process.

2. Selective Sync

Only this process receives updates.

javascript
if (lead.documents.identity_card && 
    !primaryProcess.attachments.identity_card_url) {
    
  await Processes.update(primaryProcess.id, {
    attachments: {
      identity_card_url: lead.documents.identity_card
    },
    tasks: {
      collect_identity_card: true
    }
  })
}

3. Prevent Overwrites

javascript
if (!primaryProcess.tasks.collect_identity_card) {
  // Only update if not already completed
}

The system never overrides existing work.

Why This Works

✔️ One clear source of truth

✔️ No data leakage across processes

✔️ No accidental overwrites

✔️ Predictable system behavior

Example Flow

Lead:

json
{
  "documents": {
    "passport": "url",
    "identity_card": null
  }
}

Process (Before):

json
{
  "tasks": {
    "collect_identity_card": false
  }
}

After Lead Update:

json
{
  "tasks": {
    "collect_identity_card": true
  }
}

Golden Rules

🥇 Always define a primary process

🥇 Never sync to all processes

🥇 Never overwrite existing data

🥇 Only fill missing information

Summary

Data synchronization is one of the most critical aspects of building scalable systems.

The decision of where data flows determines whether your system becomes:

❌ Confusing

or

✅ Reliable and scalable

Comments

Want to join the conversation?

No comments yet. Be the first!