ANS-1821 · SUITESCRIPT DEVELOPMENT

How to Retain Parameters in NetSuite Suitelets After Page Refreshes?

Learn how to persist data across requests in SuiteScript 2.x Suitelets by utilizing session objects to prevent loss of initial parameters during page interactions.

Short answer

When interactive selection fields in a Suitelet trigger a page refresh, initial parameters can be lost. To prevent this, store and retrieve parameters using the N/runtime module's Session.set(options) and Session.get(options) functions. This ensures data persistence and proper functionality across subsequent requests.

Scenario

NetSuite Suitelets often include interactive selection fields (e.g., dropdowns, lists) that, when interacted with, can trigger a page refresh. This refresh re-GETs the Suitelet page without preserving the initial parameters that were originally sent, leading to a loss of context and preventing the fields from functioning as intended.

Solution

To maintain data integrity and ensure proper functionality when interactive selection fields in a Suitelet cause a page refresh, parameters can be saved and reacquired using the NetSuite N/runtime module's session objects.

  1. When parameters are initially received or modified, save them to the session using N/runtime.Session.set(options).

  2. Upon subsequent page loads or refreshes, retrieve the stored parameters from the session using N/runtime.Session.get(options).This approach ensures that even if a page refresh occurs, the Suitelet can access the necessary parameters from the session, allowing interactive fields to operate correctly. Note that certain field types, such as MULTISELECT, may have specific limitations or require alternative implementations in SuiteScript 2.x Suitelets.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant