I feel like I'm missing something... I have a vali...
# suitescript
w
I feel like I'm missing something... I have a validateField script that is executed and returns false, but I can still select another field and leave the incorrect values in the field. Shouldn't it prevent me from leaving the field? I have stepped through the code in the console and see that the final value it returns is
false
I use the same function in beforeSave and it prevents the save at least. Do I have to reset the value to a previous one stored in pageInit? The field is of type Text Area.
m
I've been seeing the same thing for years on certain field types - it feels like it really defeats the purpose of the
validateField
entry point being separate from
fieldChanged
. When I contacted support about it they blamed it on Chrome and didn't seem to understand why it's not only confusing, but dangerous considering it essentially ignores that you're returning
false
. I've pretty much given up on it and instead just clear out values in
validateField
alongside returning
false
.
😞 1
I'd love to hear from anyone else that's been able to reliably make
return false
work in
validateField
though - I'd be more than happy to be wrong in my approach to this.
w
I added some code in pageInit and before returning false to track the valid values. But it feels a bit nasty to just revert what the user entered. I might've been some extraordinary text. 🙂 Thanks for confirming my experience at least!
I might just leave the faulty value and have a dialog as a warning, then just let the beforeSave prevent the user from saving the record.
m
The latter option would probably make for a better user experience than what I'm doing, I've mostly just been hopeful that they'll fix it eventually so I went the lazy route.