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 + Slack Integration: The Complete Step-by-Step Guide/Step 2: Send Your First NetSuite Alert to Slack with SuiteScript

Step 2: Send Your First NetSuite Alert to Slack with SuiteScript

Part 4 of 13 in the NetSuite + Slack series
Time: 30 minutes  |  Level: Some SuiteScript helps
You will learn: How to build, deploy and test a script that posts to Slack when a big order is saved.
You will need: A NetSuite sandbox, the webhook URL from Step 1, and permission to deploy scripts.

This is the fun one. By the end of this page a real NetSuite sales order will trigger a real message in Slack.

What we are building: an alert for big orders. Whenever a new sales order over a set amount is created, NetSuite posts a short message to a Slack channel. The message shows the customer and the total, with a link straight to the order.

How it works, in plain English

  1. Someone saves a new sales order.
  2. NetSuite runs a User Event script in the afterSubmit step, which means after the record has safely saved.
  3. The script checks the total. If it is below your threshold, it does nothing.
  4. If it is above, the script sends a small package of JSON to the Slack webhook.
  5. Slack shows the message in your channel.

We use afterSubmit on purpose. That way, if anything goes wrong with Slack, the sales order is already saved and the user is not affected.

What you need

  • The webhook URL from Step 1.
  • A NetSuite sandbox.
  • A way to upload files: Documents > Files > SuiteScripts in the File Cabinet.

Part A: The script

Create a file called ns_slack_big_order_ue.js and paste in the following.

/**
 * @NApiVersion 2.1
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 *
 * Posts a Slack message when a large sales order is created.
 */
define(['N/https', 'N/runtime', 'N/url', 'N/log'],
  (https, runtime, url, log) => {

    const afterSubmit = (context) => {
      // Never let a Slack problem break saving an order.
      try {
        // Only care about brand new orders.
        if (context.type !== context.UserEventType.CREATE) return;

        const script = runtime.getCurrentScript();
        const webhookUrl = script.getParameter({ name: 'custscript_slack_webhook_url' });
        const threshold  = Number(script.getParameter({ name: 'custscript_slack_big_order_min' })) || 10000;

        if (!webhookUrl) {
          log.error('Slack alert skipped', 'The webhook URL parameter is empty.');
          return;
        }

        const order = context.newRecord;
        const total = Number(order.getValue({ fieldId: 'total' })) || 0;
        if (total < threshold) return;

        const tranId   = order.getValue({ fieldId: 'tranid' });
        const customer = order.getText({ fieldId: 'entity' });
        const shipDate = order.getText({ fieldId: 'shipdate' }) || 'not set';

        // Build a link that opens the order in NetSuite.
        const domain = url.resolveDomain({ hostType: url.HostType.APPLICATION });
        const path   = url.resolveRecord({ recordType: 'salesorder', recordId: order.id });
        const link   = 'https://' + domain + path;

        const message = {
          text: ':moneybag: *Big order received*\n' +
                '*Order:* <' + link + '|' + tranId + '>\n' +
                '*Customer:* ' + customer + '\n' +
                '*Total:* $' + total.toFixed(2) + '\n' +
                '*Ship date:* ' + shipDate
        };

        const response = https.post({
          url: webhookUrl,
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify(message)
        });

        if (response.code !== 200) {
          log.error('Slack returned an error', response.code + ' ' + response.body);
        }
      } catch (e) {
        // Log it and move on. The order is already saved.
        log.error('Slack alert failed', e.name + ': ' + e.message);
      }
    };

    return { afterSubmit };
  });

What each part does

  • The header comment (@NApiVersion, @NScriptType) is required. It tells NetSuite this is a 2.1 User Event script.
  • define([...]) loads the NetSuite modules we use: N/https to call Slack, N/runtime to read settings, N/url to build the order link and N/log to write to the Execution Log.
  • context.type !== CREATE means “only run for new records”, so editing an order later does not spam the channel.
  • getParameter reads settings from the script deployment, so nothing secret or changeable is hard-coded in the file.
  • try and catch make sure a Slack outage can never stop someone from saving an order.
  • https.post sends the message. Slack replies with HTTP 200 and the text ok when it works.

Part B: Upload the script

  1. Go to Documents > Files > SuiteScripts.
  2. Click Add File and upload ns_slack_big_order_ue.js. A folder such as SuiteScripts/SlackIntegration keeps things tidy.

Part C: Create the script record

  1. Go to Customization > Scripting > Scripts > New.
  2. Choose your uploaded file and click Create Script Record.
  3. Give it a name like Slack - Big Order Alert.
  4. Set the ID to something like _slack_big_order_ue.

Add two script parameters

While still on the script record, open the Parameters subtab and add:

Label ID Type
Slack Webhook URL custscript_slack_webhook_url Free-Form Text
Big Order Minimum custscript_slack_big_order_min Currency or Decimal Number

NetSuite adds the custscript prefix automatically, so check that the final IDs match what the script reads. Save the script.

A quick note on secrets: a script parameter is fine for testing. Before you go live, read Step 3 about keeping the webhook URL safer.

Part D: Deploy it

  1. On the script record, open the Deployments subtab and click Add, or go to Customization > Scripting > Script Deployments > New.
  2. Set Applies To to Sales Order.
  3. Set Status to Testing while you experiment (it only runs for the deploying user), and Released when you are happy.
  4. Fill in the parameters: paste your webhook URL and set a low minimum (for example 100) so you can test easily.
  5. Under Audience, choose who the script should run for. Roles and Employees can both be set.
  6. Save.

Part E: Test it

  1. Create a new sales order in your sandbox with a total above your minimum.
  2. Save it.
  3. Look at your Slack test channel. Your message should appear within a few seconds.

Not there? Go to Customization > Scripting > Script Deployments, open your deployment, click the Execution Log subtab, and look for errors. Common causes are listed on the troubleshooting page.

Ways to adapt it

  • Different record? Change applies to and the record type in url.resolveRecord. For an invoice, use 'invoice'. For a purchase order, 'purchaseorder'.
  • Different trigger? Alert on edits by removing the CREATE check, or check whether a field changed by comparing context.oldRecord and context.newRecord.
  • Different channel? Create another webhook for another channel and use another deployment with its own parameter value.
  • Only certain customers or subsidiaries? Add another if that checks the field and returns early.

A note on limits

Each https.post call uses governance units (Oracle documents this per method), and a User Event script has a per-execution allowance. One Slack call per order is well within limits. If you ever need to send dozens of messages from one save, hand that work to a Map/Reduce or Scheduled script instead. See Best Practices.

What is next

Your alert works, but the webhook URL is sitting in a plain parameter. Step 3 shows how to handle secrets responsibly.


← Step 1: Create Your Slack App for NetSuite (Webhook and Bot Token)
Series overview
Step 3: Keep Your Slack Secrets Safe in NetSuite →
Share
  • Facebook

Sidebar

Ask A Question

Stats

  • Questions 6
  • Answers 6
  • Best Answers 0
  • Users 9
  • 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
74gold

74gold

  • 0 Questions
  • 20 Points
Begginer
Sophie1022

Sophie1022

  • 0 Questions
  • 20 Points
Begginer

Trending Tags

clientscript netsuite scripting suitescript
  • The SuiteScript 1.0 scripts nobody remembers: Portlets, Mass Updates and Workflow ActionsSeptember 10, 2026
  • You’re on SuiteScript 2.0, not 1.0. Here’s what that actually buys you.September 9, 2026
  • Converting a SuiteScript 1.0 Suitelet to 2.1 (and the ones that were never really forms)September 8, 2026
  • Every NetSuite certification in 2026, and the rules that quietly changedSeptember 7, 2026
  • Converting a SuiteScript 1.0 Scheduled Script to a 2.1 Map/Reduce (and why a straight port is a mistake)September 7, 2026
  • Migrating a SuiteScript 1.0 RESTlet to SS2.1 + OAuth 2.0 before the 2027.1 deadlineAugust 15, 2026
  • How to convert a SuiteScript 1.0 User Event script to SuiteScript 2.1 (with real code)August 14, 2026
  • The complete SuiteScript 1.0 to 2.1 API cheat sheet: nlapiXxx β†’ N/moduleAugust 13, 2026
  • NetSuite Error Messages: Causes and FixesAugust 11, 2026
  • How to audit every SuiteScript 1.0 script in your NetSuite account (step by step)August 11, 2026

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....

Β© 2026 The NetSuite Pro. All Rights Reserved