Using a client script, we toggle the isMandatory t...
# suitescript
d
Using a client script, we toggle the isMandatory to
true
from
false
, however, I an still able to save the record without providing a value. Why is that?
a
I assume because the validation is happening serverside, and your clientside changes to the isMandatory aren't available serverside. but I don't know that for a fact, just sepculating
you could add you own validation on recordsave in your client script
... its also possible that whatever list of mandatory fields the validation happens against is only set once when the page is loaded, and your changes aren't reflected in that list
I was naively thinking about records and forms with saved and known mandatory fields available serverside... that absolutely would NOT apply to suitelet generated forms though. if this is a suitelet generated form, you could try recreating the form with the new mandatory fields, rather than just changing their isMandatory values, that might trigger whatever native validation exists to update properly.
i.e. parameterize your isMandatory list in the GET call and only set those values once during createForm/pageLoad when logic it happens serverside that changes the list instead of updating the field directly, add it to the list and reload the form
n
It doesn't work on the client side. I always manually check if that field has value or not in the saveRecord event.
d
Ya, I see that I have to do this manually in the saveRecord. Even after years of working with NetSuite, there are always interesting nuances I find.
r
isMandatory just displays the red asterisk sign in front of the field. You still need to do the validation in saveRecord entry point if you want it from saving on client side.
👍 1