Hello, does anyone now a way to validate fields on...
# suitescript
l
Hello, does anyone now a way to validate fields on Suitelet?
validateField()
help says that "_This event executes on fields added in beforeLoad user event scripts",_ however I would need to validate fields added to a form with
addField()
k
Wouldnt you use an attached client script for your suitelet and do your own validations?
t
You can use on demand client script. You can attach a client script using clientScriptFileId . In the file you can define your `validateField`function.
l
That's what I do already, however
validateField
is not fired, even when you put breakpoint on it in browser
b
what does your code look like
l
Nothing fancy so far, Suitelet points to Client Script correctly and contains several fields added with
addField()
, then the client script looks like the following:
Copy code
function validateField(scriptContext) {
    if (!isDateCorrect(scriptContext)) {
      return false;
    }

    return true;
}

exports.validateField = validateField;

return exports;
Forcing
return false
on
validateField()
does nothing, same as putting breakpoint on it in browser
Does it make any difference when validation should happen inside Assistant?
b
keyword here is assistant
forms are the one with client script entry points
l
Assistant also has
clientScriptModulePath
property
b
its for the buttons, you have already seen how entry points dont work
do the same thing on a form to see the difference
l
Bit of a bummer, thanks though