I've been using the Validate function to check form values for errors prior to submission based on the default required fields in my form, however I have noticed a strange issue where required fields, when left blank, are initially successfully caught by the validate function if no data is added to them, but if I enter text to make it pass validation from a required field, then remove that text to make it blank again, the validate function doesn't catch that the required field is blank anymore.
Does anyone know if this is a bug or somehow by design?
Steps to replicate:
- Create a form "MainForm" referencing a sharepoint list with two or more required fields.
- Create a button to check for errors. Button onSelect code:
// Check for errors before presenting confirmation dialog
Set(
varValidateForm,
Validate(
'My SharePoint List',
Defaults('My SharePoint List'),
MainForm.Updates
)
);
// If there are no errors submit, otherwise notify
If(
IsBlank(varValidateForm),
Submit(MainForm)
,
// Otherwise highlight validation Errors.
Notify(
varValidateForm,
NotificationType.Error
)
);
- Create a new item, hit the button (should see an error about the required field being blank).
- Add some text to the first required field and hit submit (that field should no longer throw an error and it'll flag the next required field error instead).
- Remove the text entered into the initial required field and submit (the error for the first field error doesn't get flagged again despite there being no data in the field anymore).
Related Function: Validate function - Power Platform | Microsoft Learn
I don't see this bug. I tried to replicate your steps but the moment I remove the text entered into the initial required field, a red error text underneath that field will show up and said the field is required.
Hence I think maybe you made some custom code to your form to change the defaulf behavior of the form. Also, when you trigger function SubmitForm without using Validation form, the function will still validate the form against the datasource information.
So I suggest you should use the IsValid for the form to enable/disable the Submit button accordingly, something like SubmitButton.DisplayMode = If(MainForm.IsValid, DisplayMode.Edit, DisplayMode.Disabled)
Stay up to date on forum activity by subscribing.
stampcoin
75
DS-11051211-0
20
MS.Ragavendar
9