StoreConnect automatically syncs its own objects (products, orders, accounts, and others) using change events. For custom objects — those you have defined yourself in Salesforce and mapped via [Custom Data Mappings](liquid-custom-data-fields) — changes are not tracked automatically. You need to create a Salesforce record-triggered flow that calls the **StoreConnect: Sync Record Changes** invocable action whenever a record is created, updated, or deleted.

## How it works

The `SyncRecordChangesInvocable` Apex class accepts a record and the type of change (Create, Update, or Delete) and sends the event through StoreConnect's standard change event pipeline. The object must be configured in Custom Data Mappings before changes will be synced.

:::note
StoreConnect Sync must be enabled on your org. If sync is disabled, the invocable action returns an error and no change event is generated.
:::

:::note
This invocable is designed for custom objects, which bypass per-record opt-in filtering. If you use it on a standard object where per-record opt-in filtering (`StoreConnect_Sync__c`) is enabled, pass `$Record` as **Entire Resource** so the opt-in field is available for evaluation.
:::

## Set up a flow for create and update events

1. In Salesforce Setup, go to **Flows** and create a new **Record-Triggered Flow**.
2. Select the custom object you want to sync (e.g. `c_o__book__c`).
3. Set the trigger to **A record is created or updated**.
4. Set **Optimize the flow for** to **Actions and Related Records**.
5. Set the flow to run **After the record is saved**.
6. Add a **Decision** element. Create an outcome named **Create** with the condition formula `ISNEW()` = `True`. Leave the default outcome as **Update**.
7. For the **Create** outcome, add an **Action** element and select **StoreConnect: Sync Record Changes**. Set the inputs:
   - **Change Type**: `Create`
   - **Current Record**: `{!$Record}` (Entire Resource)
   - **Prior Record**: `{!$Record__Prior}` (Entire Resource)
8. For the **Update** (default) outcome, add another **Action** element and select **StoreConnect: Sync Record Changes**. Set the inputs:
   - **Change Type**: `Update`
   - **Current Record**: `{!$Record}` (Entire Resource)
   - **Prior Record**: `{!$Record__Prior}` (Entire Resource)
9. Save and activate the flow.

## Set up a flow for delete events

Delete flows require a separate flow triggered before the record is removed:

1. Create a new **Record-Triggered Flow** for the same object.
2. Set the trigger to **A record is deleted**. Salesforce automatically sets **Optimize the flow for** to **Before the record is deleted**.
3. Add an **Action** element and select **StoreConnect: Sync Record Changes**.
4. Set the action inputs:
   - **Change Type**: `Delete`
   - **Current Record**: `{!$Record}` (Entire Resource)
   - **Prior Record**: leave blank
5. Save and activate the flow.

## Action inputs

| Input | Required | Description |
|-------|----------|-------------|
| Change Type | Yes | The type of change: `Create`, `Update`, or `Delete` (case-insensitive) |
| Current Record | Yes | The record that triggered the flow. Use `{!$Record}` (Entire Resource). |
| Prior Record | No | The record before the change. Use `{!$Record__Prior}` (Entire Resource). Required for updates; leave blank for delete. |

## Action outputs

| Output | Type | Description |
|--------|------|-------------|
| Success | Boolean | `true` if the change event was sent successfully |
| Error Message | Text | Error message if the operation failed |

## POS sync

Custom objects that are also referenced in a POS Layout are synced to POS devices. When a change event is generated (either automatically or via this invocable action), the record is pushed to the POS local database on the next sync cycle. See [Custom Data Mappings](liquid-custom-data-fields) for how to configure Custom Data Mappings, and [Liquid query](liquid-query) for how to query custom objects in Liquid templates.

## Governor limits

The flow invocable runs as the user who triggered the transaction. Note that although `SyncRecordChangesInvocable` is declared `with sharing`, the underlying sync handler executes in system mode, so sharing rules, CRUD, and FLS are not enforced on the sync operations. If you expect high-volume record changes, be aware of Salesforce governor limits on invocable actions in bulk operations. Use asynchronous flow execution where appropriate.