NetSuite Insights › SuiteCloud Development
How to Show Custom Messages on NetSuite Records, Including View Mode
Client scripts do not run when a record is opened in View mode, so pageInit cannot show a banner there. The supported method is a User Event script on the beforeLoad entry point, calling context.form.addPageInitMessage() with the N/ui/message module. The script runs on the server before the form renders, so it fires on View, Edit, Create and Copy, and you filter with context.type.
That is the five-line answer. The part that actually decides whether this works in production is everything after it: which of the four message types you pick, whether the banner persists or times out, how you keep the server lookup inside governance, how you stop the banner from firing on web service loads and print jobs, and how you avoid training users to ignore it. This guide covers all of that with five scenarios from live NetSuite accounts.
Why your message disappears in View mode
This is the single most common support ticket we see on in-record messaging, and it is not a bug. It is the SuiteScript execution model working exactly as designed.
A client script runs in the browser. NetSuite only loads the client script runtime when the form is interactive, which means Create, Edit and Copy. When a user opens a record in View mode, NetSuite renders a read-only page and never initialises the client script context. Your pageInit function is never called. Neither is fieldChanged, saveRecord or anything else in that file.
A User Event script is different. It runs on the NetSuite application server, in the moment between the user clicking the link and the HTML being returned to the browser. The beforeLoad entry point fires on every render path, including View, and it receives a form object you can modify before the page is built. The Form.addPageInitMessage() method queues a message on that form, and the message is shown on the client after page initialisation completes.
| Mechanism | Runs in View | Runs in Edit | Runs in Create | Where it executes |
|---|---|---|---|---|
Client script pageInit | No | Yes | Yes | Browser |
User Event beforeLoad | Yes | Yes | Yes | Server |
| Workflow Show Message action | No | Yes | Yes | Browser (client triggers only) |
Inline HTML field added in beforeLoad | Yes | Yes | Yes | Server renders, browser displays |
That third row matters more than most teams realise. SuiteFlow is often the right first tool, and we usually argue for it in our configuration versus customization conversations. But the Show Message action is only supported on client-side triggers: Before User Edit, Before Field Edit, After Field Edit, After Field Sourcing and Before User Submit. There is no Before Record Load support for it. If someone on your team has spent a day trying to make a workflow pop a message on a record the user is only looking at, that is why it will not work, and no amount of condition tuning will change it.
Rule of thumb: if the requirement contains the words "when the user opens the record", you need beforeLoad. If it contains "when the user changes a field", you need a client script or a workflow. Decide this before anyone writes a line of code.
Pick the right messaging mechanism first
Banner messages are one of five ways to put information in front of a NetSuite user at record level. Choosing wrong is how accounts end up with a cluttered interface that nobody reads. Here is the decision table we use on customization engagements.
| You need to | Use | Why |
|---|---|---|
| Flag a condition the user should notice now, then move on | addPageInitMessage with a duration | Non-blocking, disappears, no clicks required |
| Flag a condition that stays true for the life of the record | addPageInitMessage with no duration, or an Inline HTML field | Persists until dismissed or until the field is removed |
| Force the user to acknowledge before continuing | N/ui/dialog in a client script | Modal, blocks interaction, Edit and Create only |
| Stop a bad save | beforeSubmit throwing an error, or a workflow Return User Error action | A banner is advisory, it enforces nothing |
| Explain a single field | Field help text or a field display note | Lives next to what it describes, zero code |
Two of those rows are worth underlining. A banner never prevents anything. If the business requirement is "stop AP from paying a vendor on hold", the banner is the courtesy, and beforeSubmit is the control. And a modal dialog is tempting for high-severity cases, but it cannot run in View mode either, for the same reason pageInit cannot.
The baseline script, written the way it should ship
Most versions of this script on the internet look like the snippet below, and it is correct as far as it goes. It is also not what we would deploy.
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(['N/ui/message'], (message) => {
const beforeLoad = (context) => {
if (context.type === context.UserEventType.VIEW) {
context.form.addPageInitMessage({
type: message.Type.CONFIRMATION,
message: 'This is a message in view mode',
duration: 7000
});
}
};
return { beforeLoad };
});
Three things are missing before this is production-safe.
One: it runs in contexts that have no user interface. The beforeLoad entry point does not only fire when a human opens a record. It also fires on web service GET requests, RESTlet record loads, and print. If you add a lookup or a search to this script, you have just added latency to every integration call that touches the record. Guard on runtime.executionContext.
Two: it has no error handling. A beforeLoad script that throws an uncaught exception does not fail quietly. It can prevent the record from rendering at all. A banner is a nice-to-have. It must never be able to take a sales order page down. Wrap the whole body in try/catch and log the failure.
Three: the string is hardcoded. Every change to the wording becomes a code deployment through your sandbox and a release cycle. That is one of the quieter contributors to technical debt in NetSuite. We will fix this properly in Scenario 5.
Here is the same idea, hardened:
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/ui/message', 'N/runtime', 'N/log'], (message, runtime, log) => {
const UI_CONTEXTS = [
runtime.ContextType.USER_INTERFACE
];
const beforeLoad = (context) => {
try {
// 1. Only spend cycles on a real browser render.
if (!UI_CONTEXTS.includes(runtime.executionContext)) return;
// 2. Decide which modes the banner belongs in.
const { VIEW, EDIT } = context.UserEventType;
if ([VIEW, EDIT].indexOf(context.type) === -1) return;
// 3. Evaluate the condition from data already on the record (0 units).
const onHold = context.newRecord.getValue({ fieldId: 'custbody_epiq_qa_hold' });
if (!onHold) return;
context.form.addPageInitMessage({
type: message.Type.WARNING,
title: 'Quality hold',
message: 'This order is on QA hold and will not release to the warehouse.'
// no duration: the banner stays until the user dismisses it
});
} catch (e) {
// Never let a cosmetic banner break a record load.
log.error({ title: 'QA hold banner failed', details: e });
}
};
return { beforeLoad };
});
The four message types, and what they actually signal
The N/ui/message module exposes four types. Treat them as a severity contract with your users, not as a colour picker.
| Type | Appearance | Use it for | Do not use it for |
|---|---|---|---|
CONFIRMATION | Green | An action completed, a status is healthy | Anything the user must act on |
INFORMATION | Blue | Context the user may not know, policy reminders | Routine facts already visible on the form |
WARNING | Amber | A condition that will cause a problem downstream | Low-stakes nudges |
ERROR | Red | A blocking condition the user cannot resolve here | Validation, which belongs in beforeSubmit |
Duration: the parameter most people set wrong
Per Oracle's documentation, the duration parameter is in milliseconds and the default is 0, which shows the message until it is dismissed. The widely copied sample uses duration: 7000, which means the banner is gone seven seconds after page load.
That default is backwards for most real requirements. If the message is telling a user that a customer is over their credit limit, a seven-second banner is worse than no banner, because the user who scrolled down to the line items in the first three seconds will never see it, and you will now believe the control exists. Our guidance:
- Omit
durationfor any condition that is still true when the user finishes reading. Credit holds, compliance blocks, period freezes, superseded items. - Set 5000 to 8000ms only for transient confirmations, for example "integration resynced this record 4 minutes ago".
- Never set a duration under 4000ms. It reads as a flicker and users report it as a bug.
Five scenarios from live NetSuite accounts
The generic "hello world" banner is the easy part. These are the patterns that come up repeatedly on NetSuite customization work, with the design decision behind each one.
Wholesale distributor: credit exposure invisible to the order desk
beforeLoad banner on Sales Order, View and Edit, driven by a single-unit lookupFields call against the customer. Persistent, no duration, WARNING severity, with a link straight to the customer record so the rep can escalate without hunting.define(['N/ui/message', 'N/search', 'N/runtime', 'N/url', 'N/log'],
(message, search, runtime, url, log) => {
const beforeLoad = (context) => {
try {
if (runtime.executionContext !== runtime.ContextType.USER_INTERFACE) return;
if (context.type === context.UserEventType.CREATE) return;
const customerId = context.newRecord.getValue({ fieldId: 'entity' });
if (!customerId) return;
// lookupFields costs 1 unit. A saved search would cost 10.
const cust = search.lookupFields({
type: search.Type.CUSTOMER,
id: customerId,
columns: ['creditholdoverride', 'overduebalance', 'entityid']
});
const holdText = (cust.creditholdoverride && cust.creditholdoverride[0])
? cust.creditholdoverride[0].text : '';
const overdue = parseFloat(cust.overduebalance || 0);
if (holdText !== 'ON' && overdue <= 0) return;
const custLink = url.resolveRecord({
recordType: 'customer', recordId: customerId, isEditMode: false
});
const body = (holdText === 'ON')
? 'This customer is on credit hold. Do not release to the warehouse without finance approval.'
: 'This customer has an overdue balance of ' + overdue.toFixed(2) + '.';
context.form.addPageInitMessage({
type: (holdText === 'ON') ? message.Type.ERROR : message.Type.WARNING,
title: 'Credit status',
message: body + ' <a href="' + custLink + '" target="_blank">Open customer record</a>'
});
} catch (e) {
log.error({ title: 'SO credit banner', details: e });
}
};
return { beforeLoad };
});
Field note: the creditholdoverride field is a select with values AUTO, ON and OFF, not a checkbox. AUTO means NetSuite decides from the credit limit, so AUTO plus an overdue balance is a real hold even though the field does not say ON. Check both, or you will ship a banner that stays silent on exactly the accounts you were worried about.
Discrete manufacturer: buyers reordering a superseded part
message parameter earns its keep: the buyer is one click from the right part instead of one search away.const replacementId = context.newRecord.getValue({
fieldId: 'custitem_epiq_superseded_by'
});
if (!replacementId) return;
const rep = search.lookupFields({
type: search.Type.ITEM, id: replacementId, columns: ['itemid']
});
const link = url.resolveRecord({
recordType: 'inventoryitem', recordId: replacementId
});
context.form.addPageInitMessage({
type: message.Type.INFORMATION,
title: 'Superseded part',
message: 'Service and warranty only. New demand should use '
+ '<a href="' + link + '">' + escapeHtml(rep.itemid) + '</a>.'
});
Security, and this is not theoretical. The message parameter renders HTML. Any value you concatenate into it that came from a user-editable field, an item name, a memo, a free-text custom field, an integration payload, is an injection vector against every internal user who opens that record. Escape it. A six-line escapeHtml helper replacing &, <, >, " and ' is all it takes, and it should be in your shared library module, not copied into each script.
Shared services AP: vendor compliance blocks
beforeSubmit blocks. Shipping only the banner means the control exists in the slide deck and not in the system.const COMPLIANCE_MSG = 'Vendor compliance documents are expired. '
+ 'This bill cannot be approved until procurement refreshes them.';
const beforeLoad = (context) => {
// ... guards ...
if (!vendorIsCompliant(context.newRecord)) {
context.form.addPageInitMessage({
type: message.Type.ERROR,
title: 'Compliance hold',
message: COMPLIANCE_MSG // persistent, advisory only
});
}
};
const beforeSubmit = (context) => {
if (context.type === context.UserEventType.DELETE) return;
const approved = context.newRecord.getValue({ fieldId: 'approvalstatus' });
if (approved == 2 && !vendorIsCompliant(context.newRecord)) {
throw error.create({
name: 'VENDOR_COMPLIANCE_HOLD',
message: COMPLIANCE_MSG, // same wording, enforced this time
notifyOff: true
});
}
};
Use the same string in both places. When the banner and the save error read identically, users learn the rule in one exposure. When they differ, users file two tickets.
Subscription business: renewal prompts for the right audience only
const CSM_ROLES = [1021, 1034]; // internal ids, not names
const user = runtime.getCurrentUser();
if (CSM_ROLES.indexOf(user.role) === -1) return;
const renewal = context.newRecord.getValue({
fieldId: 'custentity_epiq_renewal_date'
});
if (!renewal) return;
const days = Math.ceil((renewal.getTime() - Date.now()) / 86400000);
if (days < 0 || days > 60) return;
context.form.addPageInitMessage({
type: (days <= 30) ? message.Type.WARNING : message.Type.INFORMATION,
title: 'Renewal window',
message: 'Contract renews in ' + days + ' days.',
duration: 8000
});
Note the duration here. This is advisory and it is true for 60 days, so a persistent banner would become wallpaper. Eight seconds is enough to register and short enough that it never competes with a credit hold banner on the same page.
Multi-subsidiary group: one banner engine instead of eleven scripts
const getRules = (recordType) => {
const cache = cacheModule.getCache({
name: 'epiq_banner_rules',
scope: cacheModule.Scope.PUBLIC
});
return JSON.parse(cache.get({
key: recordType,
ttl: 900, // 15 minutes
loader: () => {
const rows = [];
search.create({
type: 'customrecord_epiq_banner_rule',
filters: [
['isinactive', 'is', 'F'], 'AND',
['custrecord_ebr_recordtype', 'is', recordType]
],
columns: ['custrecord_ebr_type', 'custrecord_ebr_title',
'custrecord_ebr_body', 'custrecord_ebr_roles',
'custrecord_ebr_modes', 'custrecord_ebr_condition']
}).run().each((r) => { rows.push(toRule(r)); return true; });
return JSON.stringify(rows);
}
}));
};
A note on Suitelets
addPageInitMessage is supported on Suitelet forms as well as User Event beforeLoad. The difference is that a Suitelet has no context.UserEventType, so there is no view-versus-edit distinction to filter on. Whatever logic decides when the message appears is entirely yours, usually driven by a request parameter or the result of the Suitelet's own processing.
What changed in 2026, and what it means for these scripts
If you are copying a beforeLoad example written in 2021, two platform shifts since then affect how you should write and deploy it.
SuiteScript 2.1 is now the standard, and the clock is running on everything else
Oracle published a staged retirement for the older scripting versions. The dates are worth putting in your roadmap rather than discovering later:
| Release | What changes | What you should do |
|---|---|---|
| 2026.2 | SuiteScript 2.1 becomes the standard scripting model for new and existing scripts | Write every new script, including banner scripts, with @NApiVersion 2.1 |
| 2027.1 | SuiteScript 1.0 enters end-of-life support, critical issues only | Inventory and triage your 1.0 estate now |
| 2028.1 | 1.0 can no longer be deployed in new accounts; 2.0 and 2.x scripts run on the 2.1 runtime by default | Test 2.0 and 2.x scripts against the 2.1 runtime before this lands |
| 2028.2 | All new and existing scripts must use SuiteScript 2.1 | Complete the migration |
Note the detail that catches teams out: the annotations @NApiVersion 2.0 and @NApiVersion 2.x are both in scope, not just SuiteScript 1.0. A script you think of as modern may still be annotated 2.x. You can filter script records by version in the UI to size the problem. Our SuiteScript 2.x and 2.1 guide covers the migration mechanics and the governance differences in detail.
NetSuite Next and the Redwood interface
NetSuite Next, the Redwood-based interface refresh, began rolling out with 2026.2. The reassuring part for this topic: User Event scripts run server-side and are generally unaffected by an interface theme change, because addPageInitMessage is a supported API rather than a DOM manipulation. The banner is rendered by NetSuite, so NetSuite restyles it.
The caveat is for anyone who went around the API. If a previous developer injected a banner with an Inline HTML field, hardcoded CSS, or jQuery against NetSuite's internal class names, that is precisely the kind of customization an interface refresh breaks. This is a good moment to audit for it, and a NetSuite health check will surface the DOM-dependent customizations in an account quickly.
From 2026.1 you can also branch on which interface the current user is running:
define(['N/runtime'], (runtime) => {
const beforeLoad = (context) => {
if (runtime.isNextActive()) {
// user is on NetSuite Next
}
};
return { beforeLoad };
});
Use it as an input to a compatibility decision, not as a compatibility test. It tells you which experience the user is in. It does not tell you that your customization behaves identically in both, and Oracle is explicit about that distinction. Test your banners in both experiences in sandbox before the account flips.
Production checklist before you deploy
This is the list our developers work through on every banner script. Most of the items exist because something on it went wrong somewhere once.
- Execution context guarded. The script returns early for anything other than a real browser render, so web service and RESTlet loads pay no cost.
- Whole body wrapped in try/catch with
log.error. A failed banner must never block a record from loading. - Governance counted. Prefer
lookupFields(1 unit) over a saved search (10 units). Read fromcontext.newRecord(0 units) whenever the value is already on the record. Never query inside a loop. - No more than two banners on any one record load. Three is noise, and the third one will not be read.
- Dynamic values escaped before they go into the
messagestring, because it renders HTML. - Deployment audience set deliberately. Not every role needs every banner. Scope at the deployment where you can, in code where you cannot.
- Log level set to Error on the production deployment, not Debug. Debug logging on a
beforeLoadthat fires on every record view will fill your execution log. - Tested across every mode in the matrix below, not only the happy path.
- Wording reviewed by the people who will read it. "custbody_qa_hold is true" is a log message, not a banner.
Test matrix
| Scenario | Expected | Commonly missed because |
|---|---|---|
| Open in View | Banner appears | This is the one everyone tests |
| Open in Edit | Per your context.type filter | Filtering only on VIEW silently hides it in Edit |
| Create new record | Usually no banner | context.newRecord is empty, lookups fail |
| Copy an existing record | Decide explicitly | COPY is its own UserEventType |
| Print to PDF | No banner, no lookup | beforeLoad fires on print too |
| Load via REST or SOAP | Script returns immediately | Adds latency to every integration call |
| Record with no related data | No banner, no error | Null customer, null item, empty field |
| A role outside the intended audience | No banner | Role ids differ between sandbox and production |
| NetSuite Next and the classic interface | Both render correctly | Only one is usually tested |
Sandbox and production differ in ways that bite this specific pattern. Internal ids for roles, subsidiaries and custom records are not guaranteed to match after a refresh. Any banner script with a hardcoded id list needs a configuration record or a script parameter, not a constant in the file.
Five ways this goes wrong
Using a banner as a control. A banner is advisory. If the business thinks the banner prevents the action, you have an audit finding waiting to happen. Pair it with beforeSubmit, a workflow Return User Error action, or an approval routing change.
Injecting the banner through the DOM. Oracle's position is that SuiteScript does not support direct DOM access and the interface should only be touched through SuiteScript APIs. Scripts that scrape NetSuite's internal class names are the first casualties of any interface change, and Redwood is exactly that.
Running an unguarded search on every load. On a transaction type that is viewed thousands of times a day, a 10-unit search inside beforeLoad is a self-inflicted performance problem that will be blamed on NetSuite rather than on the script.
Banners for information that belongs on a dashboard. "You have 14 open approvals" is a reminder or a dashboard portlet, not a banner on every customer record. Our workflow guide and saved search reminders cover that pattern better.
Seven scripts where one belongs. If your account has more than two or three separate scripts whose only output is a banner, consolidate them the way Scenario 05 describes before you add the next one.
Frequently asked questions
Why does my client script message not show in View mode?
Because NetSuite does not initialise the client script runtime for read-only record pages. The pageInit entry point only fires in Create, Edit and Copy. Move the logic to a User Event script on beforeLoad and call context.form.addPageInitMessage(), which runs server-side and therefore works in View mode.
Can a NetSuite workflow show a message on a record in View mode?
No. The SuiteFlow Show Message action is only supported on client-side triggers: Before User Edit, Before Field Edit, After Field Edit, After Field Sourcing and Before User Submit. It is not available on Before Record Load. A View-mode message needs a User Event script, or an Inline HTML field populated by a workflow.
How long does an addPageInitMessage banner stay on screen?
The duration parameter is in milliseconds, and the default is 0, which keeps the message visible until it is hidden or dismissed. Omit duration for conditions that remain true, and set an explicit value only for transient confirmations.
Can I put a link inside a NetSuite banner message?
Yes, the message parameter renders HTML, so an anchor tag works and is often the most useful thing you can add. Because it renders HTML, escape any value that came from a user-editable field or an integration before concatenating it into the string.
Which SuiteScript version should a new banner script use?
SuiteScript 2.1. It became the standard scripting model in NetSuite 2026.2, SuiteScript 1.0 enters end-of-life support in 2027.1, and all scripts must be on 2.1 by 2028.2. Scripts annotated @NApiVersion 2.0 or 2.x are included in that transition.
Will these banners still work in NetSuite Next?
Banners built with the supported addPageInitMessage API should, because User Event scripts run server-side and NetSuite renders the banner itself. Banners built by injecting HTML or CSS against NetSuite's internal markup are the ones at risk. Test both paths in sandbox, and use runtime.isNextActive() if you need to branch.
Does a beforeLoad banner script slow down integrations?
It can. The beforeLoad entry point also fires on web service and RESTlet record loads and on print. If the script performs a lookup or a search without checking runtime.executionContext, that cost is added to every API call that loads the record. Guard for USER_INTERFACE and return early.
How many banners are too many on one record?
Two. Users dismiss a third without reading it, and that habit then applies to the important banner as well. If you need more than two, the requirement is probably a subtab, a dashboard portlet or a saved search reminder rather than banners.
About the author
Santosh Krishnamoorthy is a Principal ERP Consultant at EPIQ Infotech, a certified Oracle NetSuite Alliance Partner since 2013. He works with finance and operations teams on SuiteCloud development, release readiness and ERP optimization, and the scenarios in this guide are drawn from customization and support engagements across distribution, manufacturing and subscription businesses.
Reviewed against the Oracle NetSuite Help Center documentation for Form.addPageInitMessage, the N/ui/message module, the SuiteScript 2.1 transition schedule and the Workflow Triggers Quick Reference, current as of NetSuite 2026.2.
Banner sprawl, or a banner that never fires?
EPIQ Infotech has delivered 100+ NetSuite projects with a 96% client retention rate across 24 countries. Our developers audit existing User Event scripts for governance and interface risk, consolidate duplicated banner logic, and build the enforcement layer that advisory messages cannot provide.
Talk to a NetSuite developerRelated reading
- NetSuite Customization Services, the hub for SuiteScript, SuiteFlow and custom record work
- SuiteScript 2.x and 2.1: migration, governance limits and common errors
- NetSuite configuration versus customization
- Building and testing SuiteFlow workflows
- NetSuite technical debt: measure it, cost it, fix it
- NetSuite Support Services and NetSuite Managed Services

Santosh Krishnamoorthy is a Principal ERP Consultant at EPIQ Infotech, with extensive experience in NetSuite and enterprise systems. He works with finance and operations teams to improve reporting accuracy, streamline workflows, and build ERP environments that support sustainable growth. His writing focuses on practical insights drawn from real implementation and support experience.
Free Consultation
Talk to a NetSuite Expert
Response within 1 hour




