Pop-up Windows & Alerts
Have you ever needed to open a separate pop-up window or alert to process an action on the current loaded record? NetSuite have already posted a solution on article 65115 in SuiteAnswers (available as of 2018) where native JavaScript is used to open an prompt box alert before allowing the user to close a purchase order.
Snippet code:
var input_reason = prompt('Please enter closing reason');
When they click OK after inputting a value, the value is auto-saved to the current loaded record.
Let's change this scenario now. How would you provide the user a list of options to pick from instead of a prompt input box? For reporting purposes (especially for reasons to close an order), you would ideally want users to select from a list of options in order to facilitate improved filtering on their reports. Here's a basic solution for this...
Let's change this scenario now. How would you provide the user a list of options to pick from instead of a prompt input box? For reporting purposes (especially for reasons to close an order), you would ideally want users to select from a list of options in order to facilitate improved filtering on their reports. Here's a basic solution for this...
- FIRSTLY: Build a custom Close button on the current form and hide the native close button. The coding logic to close an order can be found in the 65115 SuiteAnswers article, but when this custom close button is clicked, you will open a custom Suitelet rather than the prompt alert box. Read on... |
- SECONDLY: Create a form within a Suitelet which has the list of options and a SUBMIT button. Configure this Suitelet to the custom button.
|
- LASTLY: use the following code within the "Response.write()" function of your Suitelet to close the pop-up window, and reload the form:
response.write('<script>self.close();if(window.opener && !window.opener.closed){window.opener.location.reload();};</script>');