Are you tired of wading through a sea of spam leads cluttering your NetSuite online forms? You’re not alone. It’s one of those little annoyances that quietly siphons time and patience—like a leaky faucet dripping away your productivity. But here’s the kicker: you don’t have to put up with it, and you don’t have to rely on Google reCAPTCHA to fix the problem either (super helpful if you have your own HTML form on your website with reCaptcha there). If you’re looking for a straightforward, no-nonsense method to stop spam leads while keeping things simple and streamlined, you’ve come to the right place. Let’s cut through the fluff and get straight to the solutions.

May we introduce; The Honeypot Method:

This method of spam elimination uses a hidden field, invisible to human users but visible to bots who tend to fill out every field possible on a form whether it is visible or not.

With NetSuite, businesses can automate this process, customizing dunning letters based on the number of days an invoice is overdue, the tone of the letter, and even including past due balances. The automation ensures that reminders are timely, consistent, and less prone to human error.


Step One:

Create the Honeypot field to exist on whatever record gets created with the online form. In this example we will be handling Lead Generation Spam so we will be creating a Custom Entity field (Customization > List/Record Fields > Entity) and adding it to the Customer record. You’ll want to use a simple free text field and set to Store Value and Available Externally.



Step Two:

 – Add the Honeypot field to your online form. Since we’re working with Leads that will live in Setup > Marketing > Online Customer Forms. If you utilize Online Case Forms that will reside in Setup > Support > Online Case Form
 – Click the edit button once you choose a form. You’ll see in the select fields section where you’ll be able to find your new Honeypot field.



Step Three:

Add the script. This script will run Before Submit. Meaning after the fields have been filled in but before the record has been saved. It will check to see if the Honeypot field has data filled in and if it does it will prevent the save of the customer record. Each action is explain within the script so you know exactly what each piece does.



The Code

/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/

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

const beforeSubmit = (context) => {

try {

// Log the event type

log.debug('User Event Triggered', `Event Type: ${context.type}`);

// Only run on record creation

if (context.type !== context.UserEventType.CREATE) {

log.debug('Event Skipped', 'Not a CREATE event');

return;

}

// Runs on any new record regardless of type

const newRecord = context.newRecord;

// Log the record type and ID for debugging

log.debug('New Record Details', `Type: ${newRecord.type}, ID: ${newRecord.id}`);

// Check the honeypot field

const honeypot = newRecord.getValue({ fieldId: 'custentity4' });

// Log the honeypot field value

log.debug('Honeypot Field Value', `Value: ${honeypot}`);

// if Honeypot field has a value

if (honeypot) {

// Log spam detection before throwing the error

log.error('Spam Detected', 'The lead was identified as spam.');

// Throw an error that prevents the save

throw error.create({

name: 'SPAM_LEAD_BLOCKED',

message: 'The lead was identified as spam and will not be created.',

notifyOff: true

});

}

} catch (err) {

// Log unexpected errors for debugging

log.error('Error in beforeSubmit', err.message);

throw err; // Re-throw the error to avoid suppressing it

}

};

return {

beforeSubmit

};

});



Step Four:

Deploy the script, test it thoroughly, and check the execution log for any issues. 



Conclusion:

Tackling spam leads in NetSuite doesn’t have to be a daunting task. By implementing the Honeypot method, you can keep your online forms free of unwanted submissions without the need for Google reCAPTCHA. This simple yet effective approach combines a hidden field with a user event script to catch and block bots before they clutter your system. Not only does this streamline your lead management process, but it also ensures your team’s focus stays on genuine opportunities. Take control of your NetSuite forms today with this practical solution—your productivity will thank you!