Salesforce Rest Ops Documentation EN
Salesforce Rest Ops Documentation EN
Page 1
InForce CLI Tool - Complete Documentation
Table of Contents
1. Introduction
2. Function Overview
2.1 export_soql
3. Detailed Workflow
4. Arguments Explained
5. Expected Output
6. Error Handling
7. Best Practices
8. Example Usage
Page 2
InForce CLI Tool - Complete Documentation
1. Introduction
The `rest_ops.py` module provides functionality for exporting Salesforce data to a CSV file using
SOQL queries via the REST API. It is designed to be lightweight, efficient, and handle query errors
gracefully.
2. Function Overview
2.1 export_soql
Signature:
Description:
Executes a SOQL query using a valid Salesforce connection and exports the result to a CSV file.
3. Detailed Workflow
1. Calls `query_all()` on the Salesforce connection object using the given SOQL query.
4. Writes a CSV file with fieldnames derived from the first record.
This function uses UTF-8 encoding to support special characters in the exported data.
4. Arguments Explained
Page 3
InForce CLI Tool - Complete Documentation
- output_path: The file path where the resulting CSV will be saved.
5. Expected Output
- A CSV file saved to `output_path` containing the results of the SOQL query.
- Column headers will match the selected fields in the SOQL query.
- If no records are found, a message "No records Found" is printed and no file is created.
6. Error Handling
Example Error:
'MALFORMED_QUERY'}]
Fix:
Ensure the SOQL syntax is correct, fields exist, and API names are case-sensitive.
7. Best Practices
- Always sanitize or validate output paths to avoid file overwrite or path issues.
- Log the query and record count if integrating into larger systems.
Page 4
InForce CLI Tool - Complete Documentation
8. Example Usage
This will export all Account records with Industry = 'Technology' to the file `tech_accounts.csv`.
Page 5