NetSuite SuiteScript Development SDK - Libraries for search conversion, error handling, OAuth, and more
src folder to NetSuite using SDF
javascript
/**
* @NAmdConfig /SuiteScripts/NS-SDK/ns-sdk-amd.json
*/
`
Quick Start
$3
`javascript
define(['N/query', 'SuiteQLHelper'], function(query, SuiteQLHelper) {
// Convert a saved search to SuiteQL
const result = SuiteQLHelper.convertSearchToSuiteQL({ id: 2413 });
const sqlQuery = result.sql;
// Run the query
const results = query.runSuiteQL({ query: sqlQuery }).asMappedResults();
});
`
$3
`javascript
define(['Currency'], function(Currency) {
const amount = new Currency(100.50);
const tax = amount.multiply(0.08);
const total = amount.add(tax);
// Works directly with NetSuite fields
record.setValue('amount', total); // Sets 108.54
});
`
$3
`javascript
define(['N/search', 'searchHelper'], function(search, searchHelper) {
const mySearch = search.create({
type: search.Type.TRANSACTION,
filters: [['type', 'anyof', 'SalesOrd']],
columns: ['tranid', 'trandate', 'amount']
});
// Get all results as JSON
const results = searchHelper.getAllResults(mySearch, true, true);
});
`
Library Documentation
- Currency.js - Precision currency calculations
- Currency Code Review - Implementation analysis
- searchHelper.js - Search utilities
- errorHelper.js - Error handling
- SuiteQL Conversion Guide - Detailed conversion documentation
- Project Guide - Comprehensive project documentation
Development
$3
`bash
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Generate coverage report
`
$3
`bash
npm run lint # Check for linting errors
npm run lint:fix # Fix linting errors automatically
`
VS Code Snippets
This project includes VS Code snippets for NetSuite script boilerplate. The snippets are automatically available when you open this project in VS Code.
Available snippets:
- ue-before - User Event Before Submit
- ue-after - User Event After Submit
- mr-getinput - Map/Reduce Get Input Stage
- mr-map - Map/Reduce Map Stage
- mr-reduce - Map/Reduce Reduce Stage
- mr-summarize - Map/Reduce Summarize Stage
- And more...
Project Structure
`
ns-sdk/
├── src/FileCabinet/SuiteScripts/NS-SDK/
│ ├── lib/ # Core libraries
│ │ ├── SuiteQLHelper.js # Search to SuiteQL converter
│ │ ├── Currency.js # Precision currency handling
│ │ ├── searchHelper.js # Search utilities
│ │ ├── recordHelper.js # Record operations
│ │ ├── errorHelper.js # Error handling
│ │ ├── oauth1.0.js # OAuth utilities
│ │ ├── moment.min.js # Date/time library
│ │ └── papaparse.min.js # CSV parsing
│ └── ns-sdk-amd.json # AMD module config
├── test/ # Unit tests
├── docs/ # Documentation
├── .vscode/ # VS Code snippets
└── .claude/ # AI assistant documentation
``