So, the 'N/ui/dialog' module in SuiteScript 2.x gives nicer looking versions of the native JavaScript alert()
and confirm()
functions that match the UI theme. However, when using them in the client functions like validateField()
and onSave()
they don't pause the script execution, so if you need to return a false to do something like preventing the record from saving, it doesn't work. In fact, I believe that if you try to return false from the dialog's promise object, the function won't even see it anyway.
Now, I've seen some ways to make it work in onSave()
, but those methods don't appear to work in a scripted form due to some NS-provided values not existing in a scripted form. Also, none of these methods account for trying to use a dialog in something like the validateField()
function. When using dialog.alert()
, this isn't really an issue as a false can be returned after creating the alert regardless of the alert's promise. For example:
const onSave = (context) => {
let currRec = context.currentRecord,
a = Number(currRec.getValue({ fieldId : "custpage_first_number" })),
b = Number(currRec.getValue({ fieldId : "custpage_second_number" }));
if (a < b) {
dialog.alert({
title : "Dialog Title"
, message : "The first number is less than the second number"
})
.then(result => {
console.log(result);
});
return false;
}
return true;
};
Doesn't really work for dialog.confirm()
, though. Is there any way to get it to work in these client trigger functions?
Comments
Post a Comment