I have a dialog.confirm showing on saveRecord that...
# suitescript
n
I have a dialog.confirm showing on saveRecord that if they hit okay returns true or cancel returns false. However, when hitting okay, nothing happens and the record doesn't save.
Copy code
if (nextActionChanged == false) {
				var options = {
					title: 'Case Fields Not Changed',
					message: 'You have updated this case but have not changed the status or next action, choose YES to save or CANCEL to go back and update the case.',
				};

				dialog.confirm(options).then(function(result){
					if (result){
						return true
					} else {return false}
				});
			}
Also, this error was shown: Cannot find function then in object true.
b
Annoyingly, the dialog module returns a asynchronous Promise while the saveRecord module expects a synchronous true or false
Dont expect to use the dialog to control if a record saves without writing code to do the equivalent of hitting the save button again
n
Ahh @battk and what would that look like?
b
the easy answer is to use confirm instead
hard answer is to use a css selector to find your submit button and then call its click method
m
Here's an example of the hard answer. However I would avoid using that undocumented internal method for calling the submit click function and use native JS like bakkt suggested. Both are unsupported but DOM manipulation is less evil than using undocumented internal functions
n
@michoel @battk thanks! I went with the confirm option and it worked great. thanks