Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>SOQL Extractor and Explain PlanNew to Visual Studio Code? Get it now.
SOQL Extractor and Explain Plan

SOQL Extractor and Explain Plan

mohanchinnappan

|
6 installs
| (0) | Free
Extracts SOQL queries from Apex code in VS Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

SOQL Extractor

The SOQL Extractor is a Visual Studio Code extension designed to streamline the analysis of Salesforce Apex code by extracting SOQL, SOSL, and DML operations. It supports both local workspace files and Apex classes retrieved from a Salesforce org, generating detailed CSV and HTML reports. The extension also provides explain plans for SOQL queries, displayed in a Webview and your default browser.

Features

  • Extract SOQL, SOSL, and DML: Identifies SOQL queries, SOSL searches, and DML operations (insert, update, delete, upsert, merge) from Apex files.
  • Local and Org Support: Processes local .cls and .apex files or retrieves Apex classes from a Salesforce org via the Tooling API.
  • CSV Output: Generates a soql_extraction.csv report with details like class name, line number, query, and source, automatically opened in a VSCode side editor.
  • HTML Report with Explain Plans: Produces a soql_explain_report.html report for SOQL explain plans, displayed in a VSCode Webview and the default browser.
  • Error Handling: Robust handling for file not found errors (e.g., ENOENT), invalid class names, and API failures.

Prerequisites

  • Visual Studio Code: Version 1.85.0 or higher.
  • Salesforce CLI: Installed and configured for org authentication (sf command).
  • Node.js: Version 20.x or compatible for development.
  • Salesforce Org Access: User must have Tooling API access and permissions to query ApexClass objects.
  • Workspace: A VSCode workspace must be open to store output files.

Usage

  1. Open a Workspace:

    • Open a VSCode workspace containing Apex files or use an empty workspace for org-only analysis.
  2. Run the Command:

    • Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
    • Select MC: Extract SOQL Queries and run Explain Plan on them.

Sample

  1. Provide Input:

    • Enter your Salesforce org username (e.g., username@example.com) for authentication and org file retrieval.
    • Choose the source:
      • Local Workspace Files: Analyzes .cls and .apex files in the workspace.
      • Salesforce Org Files: Retrieves Apex classes from the org via Tooling API.
      • Both Local and Org Files: Combines both sources.
  2. View Results:

    • Output Channel: Logs processing details in the SOQL Extractor output channel.
    • CSV Report: soql_extraction.csv opens in a side editor, listing extracted queries and details.
    • HTML Report: If explain plans are generated, soql_explain_report.html opens in a VSCode Webview and your default browser, showing a styled table with query plans.

Example Output

  • CSV (soql_extraction.csv):
    class_name,start_linenumber,testClass,has_binding,soql_query,sosl_query,dml_operations,modified_soql,explain_plan,source
    AccountReportController.cls,10,false,false,"[SELECT Id, Name FROM Account]","","","SELECT Id, Name FROM Account","[{\"cardinality\": 100, \"fields\": [\"Id\", \"Name\"]}]","Org"
    
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft