Skip to main content

Enhanced SuiteQL Query Tool

A utility for running SuiteQL queries in a NetSuite instance with modern IDE-like features including syntax highlighting, auto-formatting, and optimized large data display.


Download

VersionDescriptionDownload
CDNLibraries loaded from CDN (requires internet)Download CDN Version
LocalAll libraries included locally (offline capable)Download Local Version (.zip)
Download Info
  • CDN Version: Downloads a single Suitelet file (.js). Libraries are loaded from CDN at runtime.
  • Local Version: Downloads a .zip file containing the Suitelet file and lib/ folder with all required libraries.

Features

SQL Editor (CodeMirror)

  • Syntax Highlighting - SQL keywords, strings, numbers, comments, and operators are color-coded
  • Auto-completion - SQL hints and table/column suggestions as you type
  • Line Numbers - Easy reference for query lines
  • Active Line Highlighting - Visual indicator for current cursor position
  • Bracket Matching - Highlights matching parentheses and brackets
  • Close Brackets - Automatically closes parentheses and quotes

Query Formatting

  • Auto-format SQL - One-click formatting to beautify your queries
  • Keyboard Shortcut - Press Ctrl+Shift+F to format SQL instantly

Result Display Options

FormatDescription
DataTableInteractive table with sorting, filtering, and pagination
Virtual ScrollOptimized rendering for large datasets (100+ rows per page)
CSVExport results as comma-separated values
JSONExport results as JSON format
PDFGenerate PDF documents from query results
HTMLGenerate HTML documents from query results

Theme Support

  • Dark/Light Mode Toggle - Switch between dark and light themes
  • Professional UI - Clean, modern interface based on SQL IDE best practices

Column Operations

  • Column Resizing - Drag column borders to adjust width
  • Column Sorting - Click column headers to sort ascending/descending
  • Column Filtering - Filter results by specific column values

Query Management

  • Save Queries - Save your queries locally for later use
  • Load Queries - Load previously saved queries
  • Tables Reference - Quick access to available tables and columns

Data Handling

  • Pagination - Configurable rows per page (default: 25)
  • Large Dataset Support - Virtual scrolling for datasets with thousands of rows
  • Copy to Clipboard - One-click copy of CSV/JSON results

Keyboard Shortcuts

ShortcutAction
Ctrl+Shift+FFormat SQL query
Ctrl+SpaceTrigger auto-completion

Installation

Step 1: Upload Files

For CDN Version:

  1. Upload suiteql-query-tool-enhanced-v2.js to File Cabinet

For Local Version:

  1. Upload suiteql-query-tool-enhanced-v2-local.js to File Cabinet
  2. Upload the entire lib/ folder to File Cabinet (note the folder's Internal ID)
  3. Open the script file and set libFolderID to your lib folder's Internal ID (see Configuration below)

Step 2: Create Script Record

  1. Go to Customization > Scripting > Scripts > New
  2. Select the uploaded script file
  3. Set Name: SuiteQL Query Tool Enhanced
  4. Set ID: _suiteql_query_tool_enhanced
  5. Save

Step 3: Create Deployment

  1. Go to the script record's Deployments tab
  2. Click New Deployment
  3. Set Status: Released
  4. Set Audience: Select appropriate roles
  5. Save and note the External URL

Configuration Options

The script includes several configuration variables at the top:

var datatablesEnabled = true;      // Enable DataTables format
var remoteLibraryEnabled = true; // Use CDN for libraries
var rowsReturnedDefault = 25; // Default rows per query
var queryFolderID = null; // File Cabinet folder for saved queries
var toolUpgradesEnabled = true; // Enable tool upgrade checks
var workbooksEnabled = false; // Enable SuiteAnalytics Workbooks
var virtualScrollPageSize = 100; // Rows per virtual scroll page

Local Version Configuration

For the Local Version, you must set the library folder ID:

// Set the internal ID of the folder containing your library files
// Find this ID in File Cabinet by clicking on the lib folder
var libFolderID = 12345; // Replace with your lib folder's Internal ID
How to Find Folder Internal ID
  1. Go to Documents > Files > File Cabinet
  2. Navigate to your lib folder
  3. Click on the folder name
  4. The Internal ID is shown in the folder details or URL

The script automatically queries the File table to get the correct URLs for all library files in that folder. This ensures the libraries load correctly regardless of where you upload them in the File Cabinet.


Libraries Used

LibraryVersionPurpose
CodeMirror5.65.13SQL editor with syntax highlighting
Bootstrap5.3.0UI framework
jQuery3.5.1DOM manipulation (NetSuite built-in)
DataTables1.xInteractive table display

Credits

  • Original Author: Tim Dietrich (timdietrich.me)
  • Enhanced Version: 2024 Enhancements

Licensed under the MIT License.