Very handy and quick tip. How to validate and cancel / failed validation logic in Dynamics 365 for finance and operations.. Here is
FormControlCancelEventArgs is key to return false in the case of validation fail.Very similar logic works for form data source field validate events.
[FormControlEventHandler(formControlStr(BabayeeDaForm, _BabayeDaTextBox), FormControlEventType::Validating)]
public static void BabayeeDaForm_BabayeDaTextBox_OnValidating(FormControl sender, FormControlEventArgs e)
{
var args = e as FormControlCancelEventArgs;
ret = checkFailed(' Main nahee mananah.');
args.cancel(ret );
}