Update data export/import scripts to use latest Salesforce CLI commands

- Updated sf-data-export to use 'sf data export bulk' instead of deprecated 'sf data export'
- Updated sf-data-export.ps1 to use 'sf data export bulk' command structure
- Updated sf-data-import to use 'sf data import bulk' for better compatibility
- All scripts now comply with the latest Salesforce CLI command structure
- Fixes compatibility issues with newer SF CLI versions
This commit is contained in:
reynold
2025-08-28 18:22:43 +08:00
parent 3e24d62fb2
commit 4bae7d48fa
3 changed files with 56 additions and 51 deletions

View File

@@ -208,8 +208,21 @@ if (-not (Test-SOQLQuery $finalQuery)) {
exit 1
}
# Build the sf command
$sfArgs = @("data", "export", "--query", $finalQuery)
# Build the sf command based on bulk vs regular query
if ($Bulk) {
# Use Bulk API 2.0 for large datasets
$sfArgs = @("data", "export", "bulk", "--query", $finalQuery, "--output-file", $Output, "--result-format", $Format)
if ($Wait -ne 10) {
$sfArgs += "--wait"
$sfArgs += $Wait.ToString()
}
Write-Host "Using Bulk API 2.0" -ForegroundColor Yellow
} else {
# Use regular data query for smaller datasets
$sfArgs = @("data", "query", "--query", $finalQuery, "--output-file", $Output, "--result-format", $Format)
}
# Add optional parameters
if ($TargetOrg) {
@@ -218,24 +231,6 @@ if ($TargetOrg) {
Write-Host "Target org: $TargetOrg" -ForegroundColor Cyan
}
if ($Bulk) {
$sfArgs += "--bulk"
Write-Host "Using Bulk API" -ForegroundColor Yellow
}
if ($Wait -ne 10) {
$sfArgs += "--wait"
$sfArgs += $Wait.ToString()
}
# Set output file and format
$sfArgs += "--output-file"
$sfArgs += $Output
if ($Format -eq "json") {
$sfArgs += "--json"
}
Write-Host "Output format: $Format" -ForegroundColor Cyan
Write-Host "Output file: $Output" -ForegroundColor Cyan