Scripting Popup Windows in NetSuite

When working with a record in NetSuite (whether custom or native), we have fields that are related to other record types. For example, a custom record called “Work Order” with a custom field called “Lot Check”, which is a record type itself. So, how do we set a field in the popup window of the Lot Check record from the Work Order main record? We have to use the window.opener javascript property along with the require function.

1. Create a Client script and deploy it to the “Lot Check” record, or popup record you are referencing.

2. We only want to fire this code on create AND only if it is a popup by checking the window.opener property exists

3. Pass a reference to the popup record to the setNewLotCheckComplaint function

4. In our setNewLotCheckComplaint function, we pair window.opener with require to access NetSuite modules for the main windows record, ie Work Order

5. We can utilize the currentRecord module we pass to get the record id or get values from this record (plenty more you can do as well)

6. Then, using the “rec” parameter that references the Lot Check record, we can set the field on the popup window with the value we retrieved from the main window Work Order record.

Here is the full code and visual of the outcome. It takes the value below from the main record window to then set on the popup:

“Here is the complaint from the WO”

Leave A Comment