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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build the sf command
|
# Build the sf command based on bulk vs regular query
|
||||||
SF_ARGS=("data" "export")
|
if [[ "$USE_BULK" == true ]]; then
|
||||||
|
# Use Bulk API 2.0 for large datasets
|
||||||
# Add the query
|
SF_ARGS=("data" "export" "bulk")
|
||||||
SF_ARGS+=("--query" "$FINAL_QUERY")
|
SF_ARGS+=("--query" "$FINAL_QUERY")
|
||||||
|
SF_ARGS+=("--output-file" "$OUTPUT_FILE")
|
||||||
|
SF_ARGS+=("--result-format" "$FORMAT")
|
||||||
|
|
||||||
|
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
|
# Add optional parameters
|
||||||
if [[ -n "$TARGET_ORG" ]]; then
|
if [[ -n "$TARGET_ORG" ]]; then
|
||||||
@@ -241,26 +256,6 @@ if [[ -n "$TARGET_ORG" ]]; then
|
|||||||
echo -e "${CYAN}Target org: $TARGET_ORG${NC}"
|
echo -e "${CYAN}Target org: $TARGET_ORG${NC}"
|
||||||
fi
|
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 format: $FORMAT${NC}"
|
||||||
echo -e "${CYAN}Output file: $OUTPUT_FILE${NC}"
|
echo -e "${CYAN}Output file: $OUTPUT_FILE${NC}"
|
||||||
|
|
||||||
|
|||||||
@@ -208,32 +208,27 @@ if (-not (Test-SOQLQuery $finalQuery)) {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build the sf command
|
# Build the sf command based on bulk vs regular query
|
||||||
$sfArgs = @("data", "export", "--query", $finalQuery)
|
|
||||||
|
|
||||||
# Add optional parameters
|
|
||||||
if ($TargetOrg) {
|
|
||||||
$sfArgs += "--target-org"
|
|
||||||
$sfArgs += $TargetOrg
|
|
||||||
Write-Host "Target org: $TargetOrg" -ForegroundColor Cyan
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($Bulk) {
|
if ($Bulk) {
|
||||||
$sfArgs += "--bulk"
|
# Use Bulk API 2.0 for large datasets
|
||||||
Write-Host "Using Bulk API" -ForegroundColor Yellow
|
$sfArgs = @("data", "export", "bulk", "--query", $finalQuery, "--output-file", $Output, "--result-format", $Format)
|
||||||
}
|
|
||||||
|
|
||||||
if ($Wait -ne 10) {
|
if ($Wait -ne 10) {
|
||||||
$sfArgs += "--wait"
|
$sfArgs += "--wait"
|
||||||
$sfArgs += $Wait.ToString()
|
$sfArgs += $Wait.ToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set output file and format
|
Write-Host "Using Bulk API 2.0" -ForegroundColor Yellow
|
||||||
$sfArgs += "--output-file"
|
} else {
|
||||||
$sfArgs += $Output
|
# Use regular data query for smaller datasets
|
||||||
|
$sfArgs = @("data", "query", "--query", $finalQuery, "--output-file", $Output, "--result-format", $Format)
|
||||||
|
}
|
||||||
|
|
||||||
if ($Format -eq "json") {
|
# Add optional parameters
|
||||||
$sfArgs += "--json"
|
if ($TargetOrg) {
|
||||||
|
$sfArgs += "--target-org"
|
||||||
|
$sfArgs += $TargetOrg
|
||||||
|
Write-Host "Target org: $TargetOrg" -ForegroundColor Cyan
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Output format: $Format" -ForegroundColor Cyan
|
Write-Host "Output format: $Format" -ForegroundColor Cyan
|
||||||
|
|||||||
@@ -289,12 +289,27 @@ if [[ "$VERBOSE" == true ]]; then
|
|||||||
show_file_preview "$FILE" "$FILE_FORMAT"
|
show_file_preview "$FILE" "$FILE_FORMAT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build the sf command
|
# Build the sf command - SF CLI now uses specific commands for different operations
|
||||||
SF_ARGS=("data" "$OPERATION")
|
case "$OPERATION" in
|
||||||
|
"insert")
|
||||||
# Add the file and sobject
|
# For insert operations, use bulk import (works for all data types)
|
||||||
|
SF_ARGS=("data" "import" "bulk")
|
||||||
SF_ARGS+=("--file" "$FILE")
|
SF_ARGS+=("--file" "$FILE")
|
||||||
SF_ARGS+=("--sobject" "$SOBJECT")
|
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
|
# Add optional parameters
|
||||||
if [[ -n "$TARGET_ORG" ]]; then
|
if [[ -n "$TARGET_ORG" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user