NetSuite SuiteScript 2.0 dialog.confirm Issue Workaround
dialog.confirm
dialog.confirm is SuiteScript 2.0 implementation of native JavaScript confirm function. This enhanced version contains the following new features:
- Developers can use HTML to format the text shown to users
- It inherits NetSuite look and feel for display
Native Javascript Version | SuiteScript 2.0 Version |
| |
SuiteScript 2.0 confirm function Issue
One of the primary usage of JavaScript confirm function in NetSuite is to get the user to provide final confirmation prior to saving the record. It effectively pauses the execution of the script until the user provides an answer to the question. When SuiteScript 2.0 version of the confirm function is used to achieve the same goal, it fails.
The underlying reason for the failure is that SuiteScript 2.0 version returns a promise object and continues to execute the rest of the script instead of pausing the execution of the script until the answer is provided. When it is used in saveRecord client script trigger, SuiteScript 2.0 version will always return false regardless of option selected by the user and prevents them from saving the record.
Native Confirm process with saveRecord Trigger
When native Javascript confirm is used in saveRecord trigger, execution is paused until the answer is provided by the user. This allows developers to control the logic flow.
SuiteScript 2.0 Confirm process with saveRecord Trigger
When SS2.0 confirm is used, instead of pausing execution, it shows the dialog box with confirm options while continuing to execute the rest of saveRecord function.
Workaround Solution
As of this posting, this behavior is NOT considered as a defect. Easy workaround is to use native Javascript confirm function, however, here is our alternate solution:
Below is sample code.
If you are having trouble with implementing solutions using SuiteScript 2.0, please feel free to contact us!