The quick answer
Use a Client Script’s validateLine entry point when the current line is being committed, such as when the user clicks Add. Check the singular item sublist ID, read the selected item’s internal ID and display the reminder for configured target IDs. Return true to permit commitment after the synchronous alert is dismissed. Return a Boolean on every path.
Person, company and transaction values in these screenshots are fictional example data.
Before you start
This local exercise starts with SO-8246 for Summit Repair Solutions, containing one Service Label at 8.00. Pump Assembly usually needs a Mounting Kit, but the kit is optional. The reminder asks the operator to consider it.
The prepared Client Script is attached to a local Sales Order form model. Its target item internal ID is 501. Replace that synthetic ID with the relevant internal ID in your account, and use an appropriately configured active Client Script deployment for supported interactive entry. Deployment setup is outside this walkthrough.
The Code Editor and API harness are synthetic. The harness executes the saved JavaScript with local currentRecord and alert stubs. The sales-order preview uses a bounded model derived from that source. Neither proves deployment or execution in a NetSuite account. Browser chrome is represented by the existing in-page browser-alert stand-in.
01. Inspect the local source
Open the prepared item_line_reminder.js in the local Code Editor. The handler is mapped through the returned entry-point object. Its initial guard uses the incorrect plural sublist ID:
if (context.sublistId !== 'items') {
return true;
}
Click Run local harness. Its input is sublist ID item and item internal ID 501. The guard returns early, so the output says No browser alert while still returning true.
02. Correct the sublist guard
Change only the guard from items to item. The visible tab is called Items, but the script sublist ID is singular.
Keep the current selected-item read on the same sublist and field:
const itemId = context.currentRecord
.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'item'
});
Compare String(itemId) with the configured target IDs. For a match, call window.alert with the reminder. Keep return true after the alert and on the unrelated-sublist path, and return { validateLine } from the module.
Click Save, then Run local exercise. The saved JavaScript now emits the reminder for item 501 and returns true. This output is from the local API harness.
03. Compare ordinary and target items
Return to SO-8246, click Edit, and open Items. Select Service Label and click Add. A second Service Label commits without the custom reminder.
Select Pump Assembly and click Add. The reminder reads: Check whether the mounting kit is needed for this item.
Click OK. The synchronous alert returns, the handler returns true, and Pump Assembly commits as the third line. OK acknowledges the message; it does not determine that the kit is required.
04. Add the optional kit and save
For this example, decide the kit is appropriate. Select Mounting Kit and click Add manually. The script does not insert it.
Click Save. Confirm the same SO-8246 customer and the total of 220.00: two Service Labels at 8.00 each, Pump Assembly at 180.00 and Mounting Kit at 24.00.
Open Items and confirm all four saved lines remain. Enlarging the full image also shows their quantities, rates and amounts.
This verifies the local form’s retained result. Opening a saved order does not run validateLine against every stored line. The example does not inspect existing companion lines or quantities, suppress duplicate reminders, decide business necessity, or enforce imports and integrations.
Common questions
How do I permit the target line after the reminder?
Return true after the synchronous alert is dismissed. Returning false blocks commitment. The handler must return a Boolean on every path; this example also returns true for ordinary items and unrelated sublists.
Why does the guard use item instead of Items?
Items is the visible tab label. The sales-order transaction sublist’s script ID is item. The selected-item field ID within it is also item.
Can I use N/ui/dialog instead of window.alert?
N/ui/dialog is asynchronous and cannot pause validateLine while waiting for the user. Do not return its Promise in place of the required Boolean. Returning true immediately can commit the line before the dialog resolves; returning false rejects the current validation cycle. Use a synchronous browser alert for this informational pattern, or design asynchronous interaction in a different client event separately.
Does this add a kit or avoid reminders when the kit is already present?
No. The operator adds the optional kit manually. This example does not examine other lines, and it can remind again when a target line is edited and recommitted. Add separate logic if those behaviors are required.
Is this Inventory Level Warnings or a server-side item rule?
No. The custom reminder is separate from the user’s built-in Inventory Level Warnings preference and shortage messages. A Client Script runs in supported NetSuite browser UI contexts when its deployment and form targeting apply. It does not enforce CSV imports, web services, integrations or other non-UI entry paths.