nathanw
12/23/2020, 7:57 PMValidateField
function that shows a modal.
Example, Field value cannot be less than 0, When a user enters -1 a Modal appears informing them "Cannot be less than 0"nathanw
12/23/2020, 7:59 PMif(valid){
return true;
}else {
dialogModule.create({
title: 'Invalid Amount',
message: 'Cannot be less than 0'
});
return false;
}
nathanw
12/23/2020, 8:00 PMnathanw
12/23/2020, 8:34 PMmichoel
12/23/2020, 9:06 PMMTNathan
12/28/2020, 3:11 PMN/ui/dialog
and returning false
in validateField
without causing issues. My current workaround is to clear out the field that fails validation so it doesn't keep failing but that's not great UX.nathanw
01/04/2021, 8:47 PMnathanw
01/04/2021, 8:52 PMif (valid) {
return true;
} else {
function zeroOut(scriptContext) {
currentRecordModule.get().setValue({
fieldId: 'discountrate',
value: 0,
ignoreFieldChange: false,
forceSyncSourcing: true
});
}
dialogModule.alert({
title: 'Invalid Discount Percent or Amount',
message: 'Invalid Discount Percent or Amount. Must be less than 20%'
}).then(zeroOut).catch(zeroOut);
return true;
}
I admit it's not correct, no point in calling zeroOut
in both the .then
and the .catch
and I could have messed with the ignoreFieldChange
some,
The Essential part is that you have to return true
or infinite loop.MTNathan
01/04/2021, 8:59 PMdialog.alert
to avoid an infinite loop. Rather frustrating since that could just as effectively be done as the first thing in the fieldChanged
entry point and the user doesn't get the benefit of modifying their entry (as opposed to starting from scratch), but if that's what works, I guess it's our best option for now. Thanks for responding!