> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.metalocator.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Managing Multiple Data Sources with Import Mapping

When you work with multiple data sources (e.g., **Salesforce, Google, SFTP**), it’s critical to control which records synchronize with which feed. Without careful management, one import could accidentally overwrite or delete records from another source.

MetaLocator solves this by allowing you to create a custom field called **Segment** and use [Import Mapping](https://support.metalocator.com/en/articles/4632960-advanced-import-mapping-transformations) to scope records by their source.

This approach ensures that:

* Only records belonging to a specific data source are updated or deleted during synchronization.
* Records from other sources remain unaffected.

## When to Use Segment-Based Import Mapping

You should implement this method if:

* You manage **multiple data sources** and want to keep their records separate.
* You need **granular control** over which records get updated or deleted.
* You want to avoid overwriting or removing records that belong to other imports.

---

## 1. Create the Custom Segment Field

Start by creating a field that identifies which data source each record belongs to.

1. Go to **Locations > Fields** in the MetaLocator Admin.
2. Click **New Field**.
3. Name the field `segment`.
4. Choose **Text** as the field type.
5. Save the field.

You will use this field to label records with their source, for example:

* `segment = Salesforce`
* `segment = Google`
* `segment = SFTP`

---

## 2. Configure Import Mapping

Next, create an [import mapping](https://support.metalocator.com/en/articles/4632960-advanced-import-mapping-transformations) so that all records imported by a specific job are automatically tagged with the right segment value.

1. Go to **Tools > Import Mapping**.
2. Click **New** to create a new mapping.
3. Set the **Mapping Type** to **JobId**.
4. Choose the **Job ID** for the data source you are importing (e.g., your Salesforce import job under **Background Jobs**).
5. In **Field Name**, select the `segment` field you just created.
6. In **Transformation Template**, enter the name of the data source (e.g., `Salesforce`).
7. Save the mapping.

[![](https://storage.crisp.chat/users/helpdesk/website/-/1/f/c/6/1fc647432f561100/e5e4df7e-a14c-4fa9-aa58-b98228_kof0gq.png)](https://downloads.intercomcdn.com/i/o/yn1vvwtq/1777431061/c65ebe445d7f3a7650eabb23586a/image.png?expires=1794513600&signature=0dc1820d4ccbf9c06e6c0ab5a3c7baf4818241177198b6d4cc7564ea8dfba756&req=dScgEc19nIFZWPMW1HO4zTIVCppx7SDlUIfu3pYMqsDlsXd4l%2FLZrZibvksJ%0ATuQtd3XcglGFR3yZF%2Fs%3D%0A)

This ensures that every record imported by that job is automatically labeled with the correct segment.

---

## 3. Enable Sync Logic for the Job

Once segmenting is set up, you can safely enable deletion logic so that only records in that segment are updated or removed when missing from the import file.

## Steps:

1. **Open the Existing Job**

* Go to **Background Jobs**.
* Locate the job you want to update (e.g., Salesforce import job).
* Click **Actions > Edit Import Settings**.
2. **Review Mapping Rules**

* Click **Save and Continue** until you reach the **Import Options** screen.
* Confirm that the mapping is correctly assigning `segment = Salesforce`.
3. **Configure Sync Logic**

* Under **Options**, set:

* **Update Existing and Insert New**
* **Update Where:** `segment = Salesforce`
* **Delete Where:** `segment = Salesforce`

This ensures that only Salesforce records are updated or deleted when missing from the file.
4. **Save and Test**

* Save your changes.
* Run a test import to verify that:

* Records with `segment = Salesforce` are updated or deleted as expected.
* Records with other segments remain unaffected.

---

## What Happens After Setup

* **Records with `segment = Salesforce`**  
Will be deleted if they no longer exist in the Salesforce import file.
* **Records without `segment = Salesforce`**  
Will remain in MetaLocator even if they are missing from the file, preventing accidental deletion of other data.

This keeps multiple data sources in sync without interfering with each other.

---

## 4. Best Practices

* **Use Clear Segment Values**  
Choose meaningful names like `Salesforce`, `SFTP`, or `Google` so that data ownership is easy to identify.
* **Create One Mapping Per Source**  
Set up separate JobId mappings for each import job.
* **Test Carefully**  
Always run test imports with deletion logic enabled before doing production imports.
* **Document Your Setup**  
Keep a record of which segment values map to which data source to help your team maintain the system over time.

---

## Example Configuration

**Goal:** All records from Salesforce should be tagged with `segment = Salesforce` and deleted if they are missing from the Salesforce import file.

**Example Mapping:**

| Setting | Value |
| --- | --- |
| Mapping Type | JobId |
| JobId | Salesforce Import Job ID |
| Field Name | segment |
| Field Value | Salesforce |

After configuration, MetaLocator will keep Salesforce records in sync — updating or deleting only those records — without affecting data from other sources.