sf-utils-cli
v1.0.6
Published
A modern, web-based interface for executing SOQL queries, Anonymous Apex, and DML operations against Salesforce orgs with Monaco Editor
Maintainers
Readme
⚡ Salesforce Utils CLI
A modern, web-based interface for executing SOQL queries, Anonymous Apex, and DML operations against Salesforce orgs.
✨ Features
🔍 SOQL Query Execution
- Execute SOQL queries with syntax highlighting
- Support for Tooling API queries
- Smart autocomplete for SObjects and fields
- Real-time field suggestions based on your org's metadata
- Relationship field navigation (e.g.,
Account.Owner.Name) - Query history with timestamps and record counts
⚡ Anonymous Apex Execution
- Execute anonymous Apex code directly from the browser
- View debug logs in real-time
- See compilation and execution status
- Detailed error messages with stack traces
📊 Data Management (DML Operations)
- Insert - Create new records in bulk
- Update - Modify existing records
- Delete - Remove records with confirmation
🎨 Modern UI Features
- Dark theme interface
- Monaco Editor with IntelliSense
- Sortable and filtable data tables
- Pagination for large result sets
- CSV export functionality
- Keyboard shortcuts (Ctrl/Cmd + Enter to execute)
💾 Query History
- Automatically saves successful queries
- Stores up to 50 recent queries
- View timestamp, record count, and org username
- One-click to reload previous queries
- Persistent storage using localStorage
Screenshots





🚀 Installation
Prerequisites
- Node.js (v14 or higher)
- Salesforce CLI (
sf) installed and authenticated - mohanc sf plugin. Install it with:
sf plugins install sfdx-mohanc-plugins
- At least one Salesforce org authenticated with the CLI
Install
npm install -g sf-utils-cli🎯 Usage
Starting the Server
Production mode:
sf-utilsThe server will start on http://localhost:3456
Error: Port alredy in use
❌ Error: Port 3456 is already in use!
Find and kill the process using port 3456:
lsof -ti:3456 | xargs kill -9
# or on Windows:
netstat -ano | findstr :3456
Connecting to a Salesforce Org
- Enter your Salesforce org username or alias in the connection field
- Click Connect
- Wait for the green checkmark confirming connection
Tip: Use Salesforce CLI aliases for easier connection:
sf org login web --alias production
sf org login web --alias sandboxThen simply use production or sandbox in the connection field.
📚 Examples
1. SOQL Queries
Basic Query
SELECT Id, Name, Industry, AnnualRevenue
FROM Account
WHERE Industry = 'Technology'
LIMIT 10Query with Relationships
SELECT Id, Name, Owner.Name, Owner.Email,
(SELECT Id, Subject, Status FROM Tasks)
FROM Account
WHERE CreatedDate = THIS_MONTHLIKE Query
SELECT Name, Code, DeveloperName
FROM AttributeDefinition
WHERE DeveloperName LIKE 'ATT_%'
NOT LIKE Query
SELECT Name, Code, DeveloperName
FROM AttributeDefinition
WHERE NOT DeveloperName LIKE 'ATT_%'
Aggregate Query
SELECT Industry, COUNT(Id) AccountCount, AVG(AnnualRevenue) AvgRevenue
FROM Account
WHERE Industry != null
GROUP BY Industry
ORDER BY COUNT(Id) DESCTooling API Query
Enable "Use Tooling API" checkbox
SELECT Id, Name, Body, ApiVersion
FROM ApexClass
WHERE Name LIKE 'Test%'
ORDER BY Name2. Anonymous Apex Code
Update Records Based on Query
List<Account> accts = [
SELECT Id, Name
FROM Account
WHERE Name != null
];
for (Account a : accts) {
a.Name2__c = a.Name;
}
update accts;
System.debug('Updated ' + accts.size() + ' accounts.');Bulk Update with Custom Objects
List<AttributeDefinition> ads = [
SELECT Name, Code, DeveloperName
FROM AttributeDefinition
WHERE NOT DeveloperName LIKE 'ATT_%'
];
for (AttributeDefinition a : ads) {
a.DeveloperName = a.Code;
}
update ads;
System.debug('Updated ' + ads.size() + ' AttributeDefinitions.');Data Processing and Logging
// Calculate and log opportunity statistics
List<Opportunity> opps = [
SELECT Id, Name, Amount, StageName, CloseDate
FROM Opportunity
WHERE CloseDate = THIS_YEAR
];
Decimal totalAmount = 0;
Integer closedWon = 0;
for (Opportunity opp : opps) {
if (opp.Amount != null) {
totalAmount += opp.Amount;
}
if (opp.StageName == 'Closed Won') {
closedWon++;
}
}
System.debug('Total Opportunities: ' + opps.size());
System.debug('Closed Won: ' + closedWon);
System.debug('Total Amount: $' + totalAmount.setScale(2));3. DML Operations
Insert Records
Format: Object:Field1,Field2|value1,value2|value3,value4
Account:Name,Industry,AnnualRevenue|Acme Corp,Technology,1000000|Global Inc,Finance,5000000Update Records
Format: Object:Id,Field1,Field2|recordId,value1,value2
Account:Id,Name,Industry|001XXXXXXXXXXXXXXX,Updated Acme Corp,TechnologyDelete Records
Format: Object:Id1,Id2,Id3
Account:001XXXXXXXXXXXXXXX,001YYYYYYYYYYYYYYY⚙️ Features in Detail
Autocomplete (IntelliSense)
The editor provides intelligent autocomplete:
- SOQL Keywords: Type
SEL→ suggestsSELECT,WHERE,ORDER BY, etc. - SObject Names: After
FROM, get a list of all objects in your org - Field Names: After
SELECT, see all fields for the queried object - Relationship Fields: Type
Account.to see related fields - Functions: Aggregate functions like
COUNT(),SUM(),AVG()
Query History
- Automatically saves successful queries
- Shows timestamp, record count, and org
- Click any query to reload it
- Delete individual queries or clear all
- Persists across browser sessions
Data Table Features
- Sorting: Click column headers to sort ascending/descending
- Search: Filter results across all columns
- Pagination: Navigate through large datasets (50 records per page)
- Export: Download results as CSV
- Nested Objects: Automatically flattens related records (e.g.,
Owner.Name)
Keyboard Shortcuts
- Ctrl/Cmd + Enter - Execute query/code
- Standard Monaco Editor shortcuts:
- Ctrl/Cmd + / - Toggle comment
- Ctrl/Cmd + D - Select next occurrence
- Alt + Up/Down - Move line up/down
🔧 Configuration
🐛 Troubleshooting
Connection Issues
Problem: "Failed to get org details"
- Verify Salesforce CLI is installed:
sf --version - Check org authentication:
sf org list - Ensure the username/alias is correct
Query Errors
Problem: "No such column 'FieldName'"
- Verify field exists in the object
- Check field API name (custom fields end with
__c) - Ensure proper permissions on the field
Apex Execution Issues
Problem: Apex code compilation fails
- Check syntax errors in your code
- Verify all variables are declared
- Ensure proper object/field API names
Performance Issues
Problem: Large query results are slow
- Add
LIMITclause to queries - Use pagination effectively
- Consider using Tooling API for metadata queries
🔒 Security Considerations
- This tool runs locally and uses your authenticated Salesforce CLI session
- No credentials are stored in the application
- All API calls use your CLI's access tokens
- Run only in trusted environments
- Do not expose the server port to public networks
📝 Best Practices
- Always test DML operations in sandbox first
- Use LIMIT clauses to avoid large data transfers
- Review queries in history before re-executing
- Enable "Use Tooling API" only for metadata queries
- Export important query results as CSV backups
- Use meaningful variable names in Apex code
- Add System.debug() statements for troubleshooting
📄 License
MIT License (c) Mohan Chinnappan
🙏 Acknowledgments
- Built with Monaco Editor - The code editor that powers VS Code
- Uses Tailwind CSS for styling
- Powered by Salesforce CLI
📞 Support
For issues related to:
- Salesforce CLI: Check Salesforce CLI Documentation
- SOQL Syntax: See SOQL Reference
- Apex Syntax: Visit Apex Developer Guide
Made with ⚡ for the Salesforce Developer Community
