Code Studio: Fragment Validator

I’m working with Fragment Validators, and am having a problem - no matter what I do, the validator never fails.

I’ve reduced my validator code to the extremely complicated:

 mats.log("Validator Triggered");
 return false;

I see the log entry in the Detective so I know that the validator was triggered but I don’t get the expected format error in the triggering form.

Is there something else I need to do to react to the validator?

Oh, and - working in 10.2, up to date on patches.

Thanks,

Randy

Morning Randy,

Your return should be an error message to display in the event the field fails validation.

‘if (valid) {

return true;

} else {

return ‘Invalid Entry Message’;

}’

Let me know how you get on.

Adam,

Thanks, I tried that format as well. This version, using the format you suggest, should also always fail and display the text following “return”. Unfortunately, it doesn’t fail either. None of the three formats offered in the Code Studio documentation work for me.

mats.log(“Validator Triggered”);
return ‘This should show as an error’;

Per the documentation, this and my original post should be OK. The previous version should cause the default “Format Invalid” label to be displayed and the record should not be saved.

In both cases, no error is displayed and the record is saved with data that “fails” validation.

It kinda looks like a bug, but I wanted to make sure I’m not missing something simple before I report it as such.

Regards,

Randy

Quick update,

Just tried the same bit of code on an instance running 10.1 and it works fine.

Randy

Afternoon Randy,

I can confirm this is not working in 10.2, as such I have raised this as bug B8237 and will update you once it has been resolved.

Adam

I can confirm the bug has now been patched and is available as 10.2.169
Thanks again for using the forum.

2019-03-01%2014_46_30-Window