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:
@@ -229,11 +229,26 @@ if ! validate_query "$FINAL_QUERY"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build the sf command
|
||||
SF_ARGS=("data" "export")
|
||||
# Build the sf command based on bulk vs regular query
|
||||
if [[ "$USE_BULK" == true ]]; then
|
||||
# Use Bulk API 2.0 for large datasets
|
||||
SF_ARGS=("data" "export" "bulk")
|
||||
SF_ARGS+=("--query" "$FINAL_QUERY")
|
||||
SF_ARGS+=("--output-file" "$OUTPUT_FILE")
|
||||
SF_ARGS+=("--result-format" "$FORMAT")
|
||||
|
||||
# Add the query
|
||||
SF_ARGS+=("--query" "$FINAL_QUERY")
|
||||
if [[ "$WAIT_TIME" != "10" ]]; then
|
||||
SF_ARGS+=("--wait" "$WAIT_TIME")
|
||||
fi
|
||||
|
||||
echo -e "${YELLOW}Using Bulk API 2.0${NC}"
|
||||
else
|
||||
# Use regular data query for smaller datasets
|
||||
SF_ARGS=("data" "query")
|
||||
SF_ARGS+=("--query" "$FINAL_QUERY")
|
||||
SF_ARGS+=("--output-file" "$OUTPUT_FILE")
|
||||
SF_ARGS+=("--result-format" "$FORMAT")
|
||||
fi
|
||||
|
||||
# Add optional parameters
|
||||
if [[ -n "$TARGET_ORG" ]]; then
|
||||
@@ -241,26 +256,6 @@ if [[ -n "$TARGET_ORG" ]]; then
|
||||
echo -e "${CYAN}Target org: $TARGET_ORG${NC}"
|
||||
fi
|
||||
|
||||
if [[ "$USE_BULK" == true ]]; then
|
||||
SF_ARGS+=("--bulk")
|
||||
echo -e "${YELLOW}Using Bulk API${NC}"
|
||||
fi
|
||||
|
||||
if [[ "$WAIT_TIME" != "10" ]]; then
|
||||
SF_ARGS+=("--wait" "$WAIT_TIME")
|
||||
fi
|
||||
|
||||
# Set output file and format
|
||||
case "$FORMAT" in
|
||||
"csv")
|
||||
SF_ARGS+=("--output-file" "$OUTPUT_FILE")
|
||||
;;
|
||||
"json")
|
||||
SF_ARGS+=("--output-file" "$OUTPUT_FILE")
|
||||
SF_ARGS+=("--json")
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -e "${CYAN}Output format: $FORMAT${NC}"
|
||||
echo -e "${CYAN}Output file: $OUTPUT_FILE${NC}"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -289,12 +289,27 @@ if [[ "$VERBOSE" == true ]]; then
|
||||
show_file_preview "$FILE" "$FILE_FORMAT"
|
||||
fi
|
||||
|
||||
# Build the sf command
|
||||
SF_ARGS=("data" "$OPERATION")
|
||||
|
||||
# Add the file and sobject
|
||||
SF_ARGS+=("--file" "$FILE")
|
||||
SF_ARGS+=("--sobject" "$SOBJECT")
|
||||
# Build the sf command - SF CLI now uses specific commands for different operations
|
||||
case "$OPERATION" in
|
||||
"insert")
|
||||
# For insert operations, use bulk import (works for all data types)
|
||||
SF_ARGS=("data" "import" "bulk")
|
||||
SF_ARGS+=("--file" "$FILE")
|
||||
SF_ARGS+=("--sobject" "$SOBJECT")
|
||||
;;
|
||||
"update")
|
||||
# For update operations, use bulk update
|
||||
SF_ARGS=("data" "update" "bulk")
|
||||
SF_ARGS+=("--file" "$FILE")
|
||||
SF_ARGS+=("--sobject" "$SOBJECT")
|
||||
;;
|
||||
"upsert")
|
||||
# For upsert operations, use bulk upsert
|
||||
SF_ARGS=("data" "upsert" "bulk")
|
||||
SF_ARGS+=("--file" "$FILE")
|
||||
SF_ARGS+=("--sobject" "$SOBJECT")
|
||||
;;
|
||||
esac
|
||||
|
||||
# Add optional parameters
|
||||
if [[ -n "$TARGET_ORG" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user