Let's Talk

Let's Talk.

Looking for our offices? View locations.

Article  |  12/04/2016  |  Joe Son

Talking Tech: NetSuite SuiteScript 2.0 dialog.confirm Issue Workaround

Let’s Talk Tech.

Accordion’s “Talking Tech” series explores how different CFO Technology solutions can empower finance functions to support organizational strategic initiatives – by implementing business process recommendations, optimizing operations, and capitalizing on value creation opportunities.

Now, let’s take at the Dialog.confirm in SuiteScript 2.0 in NetSuite.


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

JavaScript Native 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.


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

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


Below is sample code.

* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
* @param {dialog} dialog
function(dialog) {
//finalResult and finalResultSet are global variables
//accessible by all functions

//User provided final answer from confirm box
var finalResult = false

//Flag to indicate if user provided final answer or not
finalResultSet = false;

//Save record trigger
function saveRecord(context)
//If user have never provided a final answer,
if (!finalResultSet)
//Here you do your own saveRecord validation/automation.
//During validation/automation,
// if something fails, you would return false
// which will never get to below line.

//If everything pases, show the dialog box

‘title’:’SS2.0 Confirm’,
‘message’:’This is SuiteScript 2.0 version’+
‘Do you wish to continue?’
//If user provided a final answer from confirm box, return out
//Reset the finalResultSet flag to false
// in case user selected “Cancel” on the confirm box.
finalResultSet = false;

//return will either give the control back to user
// or continue with saving of the record
return finalResult;

//Helper function called when user
// selects Ok or Cancel on confirm box
function success(result)
//Sets value of finalResult to user provided answer
finalResult = result;
//Updates the finalResultSet flag to true
// to indicate that user has made his/her choice
finalResultSet = true;

//getNLMultiButtonByName function is undocumented client side
// function call used by NetSuite when save button is clicked
// triggering this function will simulate clicking Save button
// programmatically and force NetSuite to trigger saveRecord again
// with global variables finalResult and finalResultSet altered!

//NS Hack to call simulate user clicking Save Button

function fail(reason)
return false;

return {
saveRecord: saveRecord


Need NetSuite Support? Let's Talk.