Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sourceRecordsFilter option added #936

Merged
merged 3 commits into from
Nov 28, 2024

Conversation

nktnet1
Copy link
Contributor

@nktnet1 nktnet1 commented Nov 28, 2024

Resolves #935

Added the sourceRecordsFilter which behaves similar to targetRecordsFilter for the ScriptObject .

Unit tests for this contribution are available here:

I've written some basic documentation below.


Overview

Purpose: This feature provides an additional method to apply filters only when retrieving them from the Source environment. The filters are not applied to the Target environment.

Use case: In some scenarios, the filter condition will only work in the context of the source environment. For example, a parent "Event" object whose "Start Time" depends on children "Block" objects, but the Block objects are not being migrated. This is especially important for UPSERT operations, as this relies on equivalent Source and Target objects (by their externalId) to be matched to determine whether to UPDATE or INSERT. With the source-only condition never satisfying any Target objects, only INSERT will be used, resulting in duplicate records.

Examples of Using Source Record Filter

Supposed you have an Event whose Start Time is calculated by the minimum Block time:

block-type

The settings below will retrieve all Event records made after 2024 from the Source, then insert all records retrieved to the Target without applying the same filter.

{
  "query": "SELECT Id, Start_Date1__c FROM Event__c",
  "targetRecordsFilter": "CALENDAR_YEAR(Start_Date1__c) >= 2024"
}

Understanding the TargetRecordsFilter Syntax

The sourceRecordsFilter uses the same syntax as regular SOQL. Please note that this behaviour is slightly different from the targetRecordsFilter.

@salesforce-cla salesforce-cla bot added the cla:missing Missing CLA signature label Nov 28, 2024
Copy link

Thanks for the contribution! Before we can merge this, we need @nktnet1 to sign the Salesforce Inc. Contributor License Agreement.

@salesforce-cla salesforce-cla bot added cla:signed CLA signed and removed cla:missing Missing CLA signature labels Nov 28, 2024
@hknokh hknokh merged commit 99c0245 into forcedotcom:master Nov 28, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:signed CLA signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] - Apply different filters on Source vs Target environments
2 participants