The SubmitForm function in PowerApps is used to submit a form's data to the underlying data source. This function triggers the form's OnSuccess and OnFailure properties, allowing you to handle what happens after the submission is processed.
- FormName: The name of the form control that you want to submit.
Notes:
- Form Validation: Ensure that the form validation rules are set up correctly so that users provide all necessary information before submission.
- Error Handling: Properly handle errors and provide meaningful feedback to users in the OnFailure property.
Suppose you have a form named EditForm1 and a button that submits this form:
Set this code in the OnSelect property of the button to submit the form data when the button is clicked.
To handle successful submission, set the OnSuccess property of the form. For example, navigate to a different screen or display a success message:
// OnSuccess property of EditForm1
Notify("Form submitted successfully!", NotificationType.Success);
Navigate(SuccessScreen, ScreenTransition.Fade)
To handle submission failure, set the OnFailure property of the form. For example, display an error message:
// OnFailure property of EditForm1
Notify("Failed to submit the form. Please try again.", NotificationType.Error)
PowerApps – Handle Data Entry Form submission response
Suppose you have a data entry form for submitting new records to a Products table. You can use a button to submit the form and handle the outcome:
// OnSelect property of the submit button
SubmitForm(ProductForm)
// OnSuccess property of ProductForm
Notify("Product added successfully!", NotificationType.Success);
ResetForm(ProductForm);
Navigate(ProductListScreen, ScreenTransition.Fade)
// OnFailure property of ProductForm
Notify("Failed to add product. Please check your input and try again.", NotificationType.Error)