Skip to content

FlowSync-Consulting/netsuite-suitescript-utilities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetSuite SuiteScript Utilities

A collection of reusable SuiteScript 2.1 helper functions and modules for common NetSuite development tasks. These utilities are designed to improve code quality, reduce development time, and enforce best practices.

About FlowSync Consulting

FlowSync Consulting specializes in NetSuite customization, integration, and automation. These utilities reflect the code quality and architectural patterns we use in client projects.

Contact us for NetSuite consulting services →

Features

  • Date Handling - Timezone-aware date manipulation and formatting
  • Search Wrappers - Simplified saved search API with pagination support
  • Error Logging - Centralized error handling and logging framework
  • Record Utilities - Common record operations (load, save, delete) with error handling
  • Field Validation - Reusable validation functions for common field types
  • Governance Monitoring - Track governance usage and prevent limit violations
  • API Helpers - HTTP request helpers with retry logic and rate limiting

Repository Structure

src/
├── date/
│   ├── format.js          # Date formatting utilities
│   ├── timezone.js        # Timezone conversion helpers
│   └── business-days.js   # Business day calculations
├── search/
│   ├── wrapper.js         # Simplified search API
│   ├── pagination.js      # Automatic result pagination
│   └── filters.js         # Filter builder utilities
├── logging/
│   ├── logger.js          # Centralized logging framework
│   ├── error-handler.js   # Error handling utilities
│   └── governance.js      # Governance monitoring
├── record/
│   ├── operations.js      # Safe record operations
│   ├── validation.js      # Field validation utilities
│   └── lookups.js         # Field lookup helpers
└── http/
    ├── request.js         # HTTP request wrapper
    ├── retry.js           # Retry logic for API calls
    └── rate-limit.js      # Rate limiting utilities

Installation

  1. Download the utility modules you need
  2. Upload to FileCabinet: /SuiteScripts/lib/
  3. Reference in your scripts:
/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
define(['./lib/logger', './lib/record/operations'],
    (logger, recordOps) => {
        // Your script logic
    });

Usage Examples

Date Formatting

define(['./lib/date/format'], (dateFormat) => {
    const formatted = dateFormat.toISO(new Date());
    // Returns: "2026-03-20T10:30:00Z"

    const userFriendly = dateFormat.toDisplay(new Date());
    // Returns: "3/20/2026"
});

Safe Search with Pagination

define(['./lib/search/wrapper'], (searchWrapper) => {
    const results = searchWrapper.runPaginated({
        type: 'customer',
        filters: [['stage', 'is', 'CUSTOMER']],
        columns: ['entityid', 'email']
    });

    results.forEach(customer => {
        log.audit('Customer', customer.getValue('entityid'));
    });
});

Centralized Error Logging

define(['./lib/logging/logger', './lib/logging/error-handler'],
    (logger, errorHandler) => {
        try {
            // Your logic here
        } catch (e) {
            errorHandler.log({
                error: e,
                context: 'afterSubmit',
                recordType: context.newRecord.type,
                recordId: context.newRecord.id
            });
        }
    });

Governance Monitoring

define(['./lib/logging/governance'], (governance) => {
    governance.checkUsage(); // Logs current usage

    if (governance.isNearLimit()) {
        log.audit('Warning', 'Approaching governance limits');
    }
});

Code Quality Standards

All utilities include:

  • Comprehensive JSDoc comments
  • Error handling with detailed logging
  • Governance limit awareness
  • Unit test examples (coming soon)
  • Inline usage documentation

SuiteScript Version

These utilities are written for SuiteScript 2.1 (the current standard). For SuiteScript 1.0 compatibility, see the legacy branch.

Contributing

Found a bug or have a utility to contribute? Open an issue or submit a pull request. All contributions should:

  • Include JSDoc comments
  • Follow the existing code style
  • Include usage examples
  • Handle errors gracefully

License

MIT License - see LICENSE file for details.

Contact


Status: 🚧 Work in progress - utilities being added incrementally

Roadmap:

  • Date/time utilities (in progress)
  • Search wrappers (in progress)
  • Logging framework (planned)
  • Record operations (planned)
  • HTTP helpers (planned)
  • Unit testing examples (planned)

About

Collection of reusable SuiteScript 2.1 helper functions and modules for common NetSuite development tasks

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors