ANS-0474 · SUITESCRIPT DEVELOPMENT

How to Implement a Pop-Up Suitelet for NetSuite Record Interaction?

Utilize SuiteScript to create a pop-up Suitelet that interacts with and updates data on a parent NetSuite record, enhancing user workflows.

Short answer

The solution involves a User Event script to add a button, a Client Script to open the Suitelet, and a Suitelet Script Type that uses 'window.opener' to interact with the parent record and 'window.close()' to close itself. This architecture enables dynamic record updates from a pop-up.

Scenario

A common requirement in NetSuite is to provide users with a custom interface for data entry or selection that can dynamically update fields on an existing record without navigating away from it. This often involves opening a secondary window, such as a Suitelet, to perform specific actions and then relaying the results back to the original record.

Solution

To enable dynamic interaction between a pop-up Suitelet and a parent NetSuite record, implement the following script architecture:

  1. User Event Script

    Deploy a User Event script to add a custom button to the parent record form (e.g., a Sales Order).

  2. Client Script (Parent Record)

    Attach a Client Script to the parent record. This script will handle the custom button's click event. Within this script, use 'window.open(url)' to launch the Suitelet in a new pop-up window, where 'url' is the NetSuite URL for the deployed Suitelet.

  3. Suitelet Script Type

    • Create a Suitelet Script Type.
    • Design the Suitelet form without including the standard 'Submit' button.
    • Add a custom button to the Suitelet that invokes a client-side function.
    • This client-side function within the Suitelet can interact with the original parent record screen using the 'window.opener' object. The 'window.opener' object allows execution of client-side APIs to update the opened parent record.
    • After processing is complete and any necessary updates are made to the parent record, close the Suitelet using the following JavaScript snippet:
javascriptwindow.ischanged = false;window.close();

This architecture allows for a seamless user experience where data can be manipulated in a secondary window and reflected instantly on the primary record.For reference, similar implementations can be found in scripts such as ST_CUE_OrderForm.js, ST_SSU_OrderForm.js, and ST_SUE_CUE_OrderForm.js.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant