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/Adding Custom Buttons and Form Actions in NetSuite

Adding Custom Buttons and Form Actions in NetSuite

๐Ÿงฉ Adding Custom Buttons and Form Actions in NetSuite

Introduction

NetSuite allows developers to enhance record forms with custom buttons that perform specific actions โ€” like opening Suitelets, triggering approvals, or calling REST APIs.

Adding custom buttons and form actions improves user experience by reducing clicks and automating routine tasks directly from the record interface.

You can add buttons using SuiteScript 2.x User Event Scripts or through form customization.


๐Ÿ’ก Why Use Custom Buttons?

Use CaseExample
Trigger SuiteletGenerate a custom PDF or summary view
Call RESTletSend data to Salesforce, Shopify, or 3PL
Launch WorkflowApprove or reject transactions instantly
Navigate to Saved SearchShow filtered report for selected customer
Refresh RecordReload page or re-run custom logic

โš™๏ธ Methods for Adding Buttons

  1. User Event Script (beforeLoad):
    Add buttons dynamically when a record loads.
  2. Form Customization (via UI):
    Add static buttons manually under Customization โ†’ Forms.
  3. Workflow Action:
    Add workflow-driven buttons for approvals or record changes.

๐Ÿงฑ Step-by-Step: Adding a Button via User Event Script

Step 1: Create a New Script File

Go to:
Customization โ†’ Scripting โ†’ Scripts โ†’ New โ†’ User Event Script

Step 2: Paste the SuiteScript 2.1 Example

/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 */
define(['N/ui/serverWidget', 'N/url', 'N/record'], (ui, url, record) => {

    const beforeLoad = (context) => {
        if (context.type === context.UserEventType.VIEW) {
            const form = context.form;
            const rec = context.newRecord;

            // Add a custom button
            form.addButton({
                id: 'custpage_generate_pdf',
                label: 'Generate Custom PDF',
                functionName: 'openCustomSuitelet'
            });

            // Add client script to handle button click
            form.clientScriptModulePath = './CS_GeneratePDF.js';
        }
    };

    return { beforeLoad };
});

Step 3: Create the Client Script (CS_GeneratePDF.js)

/**
 * @NApiVersion 2.1
 * @NScriptType ClientScript
 */
define(['N/url', 'N/currentRecord'], (url, currentRecord) => {

    const openCustomSuitelet = () => {
        const rec = currentRecord.get();
        const recordId = rec.id;

        const suiteletUrl = url.resolveScript({
            scriptId: 'customscript_suitelet_generate_pdf',
            deploymentId: 'customdeploy_suitelet_generate_pdf',
            params: { id: recordId }
        });

        window.open(suiteletUrl, '_blank');
    };

    return { openCustomSuitelet };
});

โœ… Result:
A โ€œGenerate Custom PDFโ€ button appears on the record form (e.g., Sales Order). Clicking it opens a Suitelet that dynamically renders a PDF for that record.


๐Ÿงฐ Example: Trigger RESTlet from Button

You can also trigger a RESTlet call directly from the client script:

fetch('/app/site/hosting/restlet.nl?script=1234&deploy=1&id=' + recordId, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ recordId })
}).then(res => res.json())
  .then(result => alert('Result: ' + result.status));

This is useful for sending data to third-party systems like Boomi, Celigo, or Salesforce.


๐Ÿง  Example Use Cases

ScenarioDescription
Custom Email ButtonSend transaction email using specific template
Recalculate TaxesRun custom script to adjust tax amounts
Mark as SentUpdate a field when an external email is triggered
View External DataOpen Suitelet to show Shopify/EDI data
Generate LabelPrint shipping label from UPS/FedEx integration

๐Ÿงฉ Adding Buttons with Dynamic Conditions

You can control button visibility using conditions in the beforeLoad function:

if (rec.getValue('status') === 'Pending Approval') {
    form.addButton({
        id: 'custpage_approve_now',
        label: 'Approve Now',
        functionName: 'triggerApproval'
    });
}

This ensures the button only appears when specific criteria are met (e.g., pending transactions).


โšก Adding Form Actions (Custom Menu Items)

You can add new form-level menu actions instead of buttons:

form.addPageInitMessage({
    type: ui.Message.Type.CONFIRMATION,
    title: 'Success',
    message: 'Button actions have been initialized!'
});

form.addSubmitButton({ label: 'Submit & Notify' });
form.addResetButton({ label: 'Clear Form' });
form.addButton({ id: 'custpage_export', label: 'Export to CSV', functionName: 'exportCSV' });

These options can enhance usability without cluttering the header bar.


๐Ÿ“ˆ UI Example: Combine Buttons + Suitelet Form

For a professional layout:

  1. Use User Event to add button.
  2. Trigger Suitelet to show interactive form.
  3. Pass the record ID as a parameter.
  4. Handle processing logic (PDF, Email, or Integration).

๐Ÿงฎ Example Workflow

Business Case: Add a button on Invoice form โ†’ โ€œSend to Accounting Portal.โ€

  • User clicks button.
  • Client Script calls RESTlet โ†’ sends data to external API.
  • RESTlet logs transaction & updates โ€œSent to Portalโ€ field.
  • Record reloads to show confirmation.

โš™๏ธ Debugging & Maintenance

IssueCauseSolution
Button not visibleWrong context typeUse context.UserEventType.VIEW only
Function not triggeredClient script not linkedAdd form.clientScriptModulePath
Script error on loadJS syntax or missing dependencyValidate in sandbox before deploying
Button duplicatedMultiple deployments activeRestrict to single deployment or filter roles

๐Ÿงฉ Best Practices

  • Always add buttons only on VIEW mode, not edit/create.
  • Use short, descriptive button labels.
  • Combine buttons into dropdown menus if too many actions.
  • Avoid long-running logic โ€” redirect to Suitelet or Map/Reduce script.
  • Track usage by adding logs (e.g., record who clicked).

๐Ÿ“š Related Tutorials

  • ๐Ÿ‘‰ Custom Portlets in NetSuite
  • ๐Ÿ‘‰ SuiteAnalytics Workbook for Dashboards
  • ๐Ÿ‘‰ Custom Email Templates in NetSuite

โ“ FAQ

Q1. Can I add multiple custom buttons on one form?
Yes, you can add as many as you like โ€” just assign unique id values.

Q2. Can I style buttons differently?
No native CSS support โ€” but you can use icons or labels for differentiation.

Q3. Can buttons call external APIs?
Yes โ€” through RESTlets or via fetch() in the client script.

Q4. Can non-admin users see custom buttons?
Yes, if their role has access to the script deployment.


๐Ÿงญ Summary

Custom buttons and form actions empower users to execute automation directly from records โ€” without navigating through menus.
From generating PDFs to triggering integrations, these buttons bridge the gap between workflows and user interaction, making NetSuite faster, smarter, and more intuitive.

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