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 VersionSuiteScript 2.0 Version

JavaScript Native Confirm Box
JavaScript Native Confirm Box

SS2.0 dialog.confirm box
SS2.0 dialog.confirm box

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.

native-confirm-process-on-saverecord-trigger
native-confirm-process-on-saverecord-trigger

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.

SS2.0 Confirm Process on Save
SS2.0 Confirm Process on Save

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:

SS2.0 Confirm Process on Save Workaround
SS2.0 Confirm Process on Save Workaround

Below is sample code.

If you are having trouble with implementing solutions using SuiteScript 2.0, please feel free to contact us!

About Abaci
Abaci is a premier NetSuite Solution Provider with deep knowledge in both business process and technology architecture. Our team is passionate about NetSuite and has an exclusive commitment to NetSuite and to providing the highest level of system expertise on its full suite of cloud-based business management applications.