This Python script connects to Salesforce, retrieves a list of Salesforce objects, including standard and custom objects, and exports detailed information about each object's fields into an Excel file. It filters out objects related to change events, history, or shares by default.
- Connects to Salesforce using provided API credentials.
- Retrieves field metadata of Salesforce objects based on criteria.
- Exports field metadata details of objects into an Excel file, with separate sheets for each object.
Before running this script, you must have:
- Python 3.x installed.
simple_salesforce
Python package installed.openpyxl
Python package installed.
-
Clone or download this repository to your local machine.
-
Install the required Python packages by running:
pip install simple_salesforce openpyxl
-
Create a
cred.py
file in the same directory as the script with your Salesforce API credentials and preferences:# cred.py SALESFORCE_USERNAME = 'your_username' SALESFORCE_PASSWORD = 'your_password' SALESFORCE_SECURITY_TOKEN = 'your_security_token' SALESFORCE_SANDBOX = True # or False
To run the script, navigate to the directory containing the script and execute:
python extractor.py
The script will connect to Salesforce, retrieve the object list, and for each object, it will fetch and export field details to an Excel file named <org_name>_export_<current_timestamp>.xlsx
.
Object and Field Selection: By default, the script fetches all objects and their fields. Modify the below section in script if you need to specify certain objects.
object_list = get_all_objects(sf) #use this to extract all objects. **THIS MAY NOT WORK IF YOU HAVE LARGE ORG**
#object_list = ['Account', 'Case', 'Main__c'] #uncomment this if you want to extract specific objects.
Ensure that your cred.py
file is securely stored and not included in version control to prevent unauthorized access to your Salesforce credentials.
Feel free to fork this repository and submit pull requests to contribute to this project. For major changes, please open an issue first to discuss what you would like to change.
MIT