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/ Real-World NetSuite Examples/Add a Suitelet to a Custom Tab Using a User Event Script

Add a Suitelet to a Custom Tab Using a User Event Script

๐Ÿง  Business Use Case

Sometimes, you want to extend the functionality of a NetSuite record form by adding:

  • A custom tab
  • A button or link to trigger a Suitelet process
  • An embedded list of related data

This pattern is especially useful when you want to:

  • Launch external processes like e-signatures, approvals, or workflows
  • Display related records (e.g., signature logs, audit trail, custom objects)
  • Maintain a cleaner, tab-based user interface for specific roles

๐Ÿ’ก What This Script Does

  • Adds a custom tab called โ€œSample Tabโ€ to a record when viewed or edited
  • Injects an HTML link to a Suitelet that passes the record ID
  • Adds a sublist to the tab to show related โ€œSignature Requestsโ€ (example use case)

โœ… Key Features

FeaturePurpose
addTab()Creates a new custom tab in the UI
addField({type: 'inlinehtml'})Injects dynamic HTML content like links
url.resolveScript()Builds the Suitelet URL with script/deployment ID
addSublist()Adds a table to the tab (static or dynamic content)

๐Ÿ’ป Script: Add a Suitelet Link in a Tab Using User Event

/**
 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 */
define(['N/record', 'N/runtime', 'N/ui/serverWidget', 'N/url'], 
function(record, runtime, serverWidget, url) {
    function beforeLoad(scriptContext) {
        var currentUserID = runtime.getCurrentUser().id;

        // Only apply on Edit or View from UI
        if ((runtime.executionContext === runtime.ContextType.USER_INTERFACE) &&
            (scriptContext.type === scriptContext.UserEventType.EDIT || 
             scriptContext.type === scriptContext.UserEventType.VIEW)) {

            // 1. Add a new Tab
            var customTab = scriptContext.form.addTab({
                id: 'custpage_sample_tab',
                label: 'Sample Tab'
            });

            // 2. Add a clickable HTML link to Suitelet on the tab
            var linkField = scriptContext.form.addField({
                id: 'custpage_new_req_link',
                type: serverWidget.FieldType.INLINEHTML,
                label: ' ',
                container: 'custpage_sample_tab'
            });

            // 3. Build the URL for the Suitelet dynamically
            var linkURL = url.resolveScript({
                scriptId: 'customscriptsuiteletsample_yourfirstsamp', // Replace with your actual script ID
                deploymentId: 'customdeploysuiteletsample_yourfirstsamp'
            }) + '&recordid=' + scriptContext.newRecord.id;

            linkField.defaultValue = '<b>Click <a href="' + linkURL + 
                '">here</a> to create a new document signature request record.</b>';

            // 4. Optional: Add a custom sublist to the same tab
            var sigSublist = scriptContext.form.addSublist({
                id: 'custpage_sig_req_sublist',
                type: serverWidget.SublistType.LIST,
                label: 'Document Signature Requests',
                tab: 'custpage_sample_tab'
            });

            sigSublist.addField({ id: 'custpage_req_name', type: serverWidget.FieldType.TEXT, label: 'Name' });
            sigSublist.addField({ id: 'custpage_req_status', type: serverWidget.FieldType.TEXT, label: 'Status' });
            sigSublist.addField({ id: 'custpage_req_created', type: serverWidget.FieldType.DATE, label: 'Date Created' });

            // NOTE: You can populate the sublist dynamically via Suitelet or Client Script
        }
    }

    return {
        beforeLoad: beforeLoad,
    };
});

๐Ÿ“Œ Implementation Tips

  • Make sure the User Event is deployed on the record type (e.g., Customer, Estimate, Sales Order)
  • Replace scriptId and deploymentId in resolveScript() with your own Suitelet values
  • Sublist content can be populated in a more advanced version using related record search results

๐Ÿงช Real-World Use Cases

Use CaseExample
โœ… Document Signing IntegrationLaunch Docusign Suitelet from a custom tab
๐Ÿš€ Approval WorkflowsTrigger a Suitelet that routes a document to managers
๐Ÿ”„ Data Sync/Sync LogDisplay synced records and provide re-sync button
๐Ÿ“ Related RecordsShow a table of related transactions or files
Share
  • Facebook

Leave a ReplyCancel reply

Sidebar

Ask A Question

Stats

  • Questions 6
  • Answers 6
  • Best Answers 0
  • Users 5
  • 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
Sophie1022

Sophie1022

  • 0 Questions
  • 20 Points
Begginer
jmargoli

jmargoli

  • 0 Questions
  • 20 Points
Begginer

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

Menu

  • 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

Quick Links

  • NetSuite Scripting
  • NetSuite Customization
  • NetSuite Advanced PDF Template
  • NetSuite Integration
  • NetSuite Reporting & Analytics

Subscribe for NetSuite Insights....

© 2025 The NetSuite Pro. All Rights Reserved