Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer peopleโ€™s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer peopleโ€™s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The NetSuite Pro

The NetSuite Pro Logo The NetSuite Pro Logo

The NetSuite Pro Navigation

  • Home
  • About Us
  • Tutorials
    • NetSuite Scripting
    • NetSuite Customization
    • NetSuite Integration
    • NetSuite Advanced PDF Templates
    • NetSuite Reporting & Analytics Guide
    • Real-World NetSuite Examples
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Home
  • About Us
  • Tutorials
    • NetSuite Scripting
    • NetSuite Customization
    • NetSuite Integration
    • NetSuite Advanced PDF Templates
    • NetSuite Reporting & Analytics Guide
    • Real-World NetSuite Examples
  • Blog
  • Contact Us
Home/ NetSuite Customization Guide: Fields, Forms, Workflows & Scripts/Dynamic SuiteScript Configuration Framework (Parameter-Driven Logic)

Dynamic SuiteScript Configuration Framework (Parameter-Driven Logic)

๐Ÿงฉ Dynamic SuiteScript Configuration Framework (Parameter-Driven Logic)

Introduction

Have you ever duplicated a script just to change a form ID, saved search, or customer type?
Thatโ€™s a common pain point in NetSuite development โ€” but itโ€™s completely avoidable.

By building a Dynamic Configuration Framework, you can make your SuiteScripts flexible, reusable, and environment-agnostic.
This framework uses script parameters, custom records, and configuration lookups to drive logic dynamically โ€” no more hardcoding IDs or constants.


๐Ÿ’ก Why Build a Configuration Framework?

ChallengeWithout FrameworkWith Framework
Hardcoded IDsScript must be edited for each client/siteConfigurable per deployment
Repeated CodeMultiple script versions for same processOne reusable codebase
Error-ProneDevelopers forget to change constantsControlled via config record
Limited ScalabilityDifficult to maintainFully environment-independent

โœ… Goal: One script, multiple uses โ€” easy to deploy, configure, and audit.


๐Ÿงฑ Step 1: Create a Configuration Custom Record

Name: Script Configuration
ID: customrecord_script_config

Field LabelIDTypeDescription
Script Keycustrecord_script_keyTextUnique identifier (e.g., โ€œInvoice_Updateโ€)
Saved Search IDcustrecord_search_idTextID of saved search
Form IDcustrecord_form_idIntegerCustom Form internal ID
Account IDcustrecord_account_idIntegerGL account ID
Subsidiarycustrecord_subsidiaryListApply config to specific subsidiary
Statuscustrecord_config_statusListActive / Inactive
Notescustrecord_config_notesLong TextDocumentation

โš™๏ธ Step 2: Create a Utility Module to Fetch Configuration

/**
 * @NApiVersion 2.1
 * @NModuleScope Public
 */
define(['N/search'], (search) => {

    function getConfig(scriptKey, subsidiaryId) {
        const configSearch = search.create({
            type: 'customrecord_script_config',
            filters: [
                ['custrecord_script_key', 'is', scriptKey],
                'AND', ['custrecord_subsidiary', 'anyof', subsidiaryId],
                'AND', ['custrecord_config_status', 'is', 'Active']
            ],
            columns: ['custrecord_search_id', 'custrecord_form_id', 'custrecord_account_id']
        });

        const result = configSearch.run().getRange({ start: 0, end: 1 })[0];
        if (!result) return null;

        return {
            searchId: result.getValue('custrecord_search_id'),
            formId: result.getValue('custrecord_form_id'),
            accountId: result.getValue('custrecord_account_id')
        };
    }

    return { getConfig };
});

โœ… Reusable across any script โ€” pass your script key and get relevant configuration instantly.


๐Ÿง  Step 3: Apply Configuration in Your SuiteScript

define(['N/record', 'N/log', './configUtil'], (record, log, configUtil) => {

    const execute = () => {
        const config = configUtil.getConfig('Invoice_Update', 2); // Subsidiary 2
        if (!config) {
            log.error('No Config Found', 'Please check customrecord_script_config');
            return;
        }

        log.audit('Loaded Config', config);

        const searchId = config.searchId;
        const formId = config.formId;
        const accountId = config.accountId;

        // Use values dynamically
        const inv = record.create({ type: 'invoice', isDynamic: true });
        inv.setValue('customform', formId);
        inv.setValue('account', accountId);
        inv.save();
    };

    return { execute };
});

โœ… You can now change saved searches, forms, or accounts without touching the script โ€” just edit your config record.


๐Ÿงฉ Step 4: Script Parameters + Custom Config (Hybrid)

For smaller deployments, use Script Parameters directly.

Example:

Define parameters in your script deployment:

  • custscript_form_id
  • custscript_search_id

Retrieve them in the script:

const formId = runtime.getCurrentScript().getParameter('custscript_form_id');
const searchId = runtime.getCurrentScript().getParameter('custscript_search_id');

โœ… Ideal for per-deployment tweaks without new records.


๐Ÿ” Step 5: Environment-Aware Configurations

Add a field in your custom record:

FieldIDDescription
Environmentcustrecord_env_typeSandbox / Production

Then use this filter in your utility:

['custrecord_env_type', 'is', runtime.envType]

โœ… Ensures scripts automatically pick the right settings based on where they run.


โšก Step 6: Configuration Validation on Deploy

Add a pre-execution validation in your script:

if (!config || !config.searchId) {
   throw Error('Invalid Configuration: Missing Saved Search ID');
}

โœ… Helps catch setup issues before processing records.


๐Ÿงฎ Step 7: Central Dashboard for Configuration Management

Create a Saved Search or SuiteAnalytics Workbook:

  • Columns: Script Key, Subsidiary, Status, Updated Date
  • Filters: Status = Active
  • Purpose: Monitor which configurations are in use

Optionally, build a Suitelet-based โ€œConfig Management Dashboardโ€ to allow non-technical users to edit configuration via UI.


๐Ÿงฐ Step 8: Real-World Use Cases

ScenarioDescription
Multi-Subsidiary ScriptsOne script fetches config by subsidiary ID dynamically.
EDI IntegrationConfigure endpoints, credentials, and search IDs without editing code.
Custom ReportsDefine saved search IDs and filters externally.
PDF TemplatesLoad custom form ID per subsidiary or department.
Automated PostingsChange GL account IDs via configuration.

๐Ÿงฉ Step 9: Benefits for Developers & Admins

โœ… One codebase across environments
โœ… No redeployment needed for logic changes
โœ… Easy to audit & document
โœ… Ideal for integration-heavy systems
โœ… Supports both sandbox and production with zero code changes


โš™๏ธ Step 10: Best Practices

CategoryTip
SecurityRestrict config record edit access to Admin/Developer roles only.
PerformanceCache results using N/cache for repeated lookups.
VersioningTrack changes in config records using System Notes.
DocumentationAdd a Notes field for change summaries.
TestingValidate config in Sandbox before deploying.

๐Ÿ“š Related Tutorials

  • ๐Ÿ‘‰ Performance Optimization for Map/Reduce Scripts
  • ๐Ÿ‘‰ Integration Logging & Monitoring Dashboard
  • ๐Ÿ‘‰ Custom Error Handling & Retry Framework

โ“ FAQ

Q1. Can admins update configurations without script access?
Yes โ€” by using custom records and role-based permissions.

Q2. Can configurations differ per subsidiary or customer type?
Yes โ€” just add those fields in your configuration record.

Q3. How does this compare to SuiteScript parameters?
Custom records are more flexible for multi-environment and multi-tenant setups.

Q4. Is caching necessary?
Yes โ€” caching improves performance by avoiding repeated search calls.


๐Ÿงญ Summary

A Dynamic Configuration Framework transforms your SuiteScript architecture into a scalable, modular, and reusable system.
Instead of rewriting code, you define your logic externally and deploy it instantly โ€” saving time, improving maintainability, and reducing deployment risk.

This approach is a hallmark of enterprise-level NetSuite customization, used by leading solution providers for integrations, automation, and global rollouts.

Share
  • Facebook

Leave a ReplyCancel reply

Sidebar

Ask A Question

Stats

  • Questions 6
  • Answers 6
  • Best Answers 0
  • Users 2
  • Popular
  • Answers
  • Rocky

    Issue in running a client script in NetSuite SuiteScript 2.0 ...

    • 1 Answer
  • admin

    How can I send an email with an attachment in ...

    • 1 Answer
  • admin

    How do I avoid SSS_USAGE_LIMIT_EXCEEDED in a Map/Reduce script?

    • 1 Answer
  • admin
    admin added an answer The issue is usually caused by following Wrong script file… September 14, 2025 at 10:33 pm
  • admin
    admin added an answer Steps to send an Invoice PDF by email: define(['N/email', 'N/render',… August 28, 2025 at 3:05 am
  • admin
    admin added an answer This error means your script hit NetSuiteโ€™s governance usage limit… August 28, 2025 at 3:02 am

Top Members

Rocky

Rocky

  • 1 Question
  • 22 Points
Begginer
admin

admin

  • 5 Questions
  • 2 Points

Trending Tags

clientscript netsuite scripting suitescript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

© 2025 The NetSuite Pro. All Rights Reserved