Patch vs. SubmitForm in Power Apps: Which Is Better?
Introduction
Power Apps helps users build applications without writing a lot of code. You
can create forms, collect information, and update records in a few simple
steps. When you build an app, you need a reliable way to save information. Two
popular options are Patch()
and SubmitForm().
Both functions save data, but they work in different ways. If you are learning
through a Power Automate Course,
understanding these functions can help you build useful business applications.
The right choice depends on your app, your data, and the level of control you
need.
![]() |
| Patch vs. SubmitForm in Power Apps: Which Is Better? |
What Is SubmitForm in Power Apps?
Subm itForm() is a function that saves information entered into a form. It
works with Edit form controls in Power Apps.
Imagine you are building an employee registration app. The form
has fields for the employee's name, email, phone number, and department. After
filling in these fields, the employee clicks the Submit button.
You can use this formula:
SubmitForm(EditForm1)
Here, EditForm1
is the name of the form.
Power Apps collects the form values and sends them to the
connected data source. It also handles form-level validation and reports
whether the submission succeeds or fails.
You can use the form's OnSuccess property to show a success message. Its OnFailure property
can display an error message when the submission fails.
This makes SubmitForm() a good choice for applications with
standard data entry forms.
What Is Patch in Power Apps?
Patch() is a
function that creates or updates records in a data source. It gives you more
control over the information you want to save.
For example, imagine an employee's phone number has changed. You
want to update the phone number without changing the employee's other details.
You can use this formula:
Patch( Employees, LookUp(Employees, ID = 101), { Phone: "9876543210" })
In this example, Power Apps finds the employee whose ID is 101 and
updates the Phone field.
The LookUp()
function finds the required record. The Patch() function then applies the change to that
record.
You can also use Patch() to create new records or update several
fields at once. It is useful when your app has custom controls instead of a
standard form.
How Does SubmitForm Work?
The SubmitForm() function
works directly with a form connected to a data source, such as SharePoint or
Dataverse.
Here is how it usually works:
1. The user opens the form.
2. The user enters the required information.
3. Power Apps checks the form's validation rules.
4. The user clicks the Submit button.
5. Power Apps sends the information to the data source.
6. The app responds based on the submission result.
For example, a leave request app may collect the employee's name,
leave dates, and reason. Once the employee submits the form, Power Apps saves
the information.
You can display a confirmation message by using the form's OnSuccess property:
Notify( "Request submitted successfully", NotificationType.Success)
This message appears after a successful submission when the
formula is placed in the appropriate property.
Always configure error handling too. This helps users understand
when a request could not be saved.
How Does Patch Work?
Unlike SubmitForm(),
Patch()
does not require a form control. You can use values from text inputs,
dropdowns, date pickers, and other controls.
For example, suppose your app has two text inputs named txtName and txtEmail. You want
to save their values as a new employee record.
Use this formula:
Patch( Employees, Defaults(Employees), { Name: txtName.Text, Email: txtEmail.Text })
Here, Defaults(Employees)
tells Power Apps to create a new record using the data source's default values.
The formula then sets the employee's name and email.
This approach is useful when you want to design a custom screen
and save only selected values.
If you are learning through Power Automate Online Training, these data-saving methods can also
help you understand how apps create records that later trigger automated
workflows.
Patch vs. SubmitForm: What Is the Difference?
The main difference is how you control the saving process.
SubmitForm() works with a
form control. It uses the form's field settings and validation behavior. This
makes it easier to use when users enter several details at once.
Patch() gives you
more direct control over the fields you want to create or update. It works well
when you need to change a single value or save data from custom controls.
For example, a customer registration app may use SubmitForm() to save
a complete form. A task management app may use Patch() to change a task's status when a user clicks
a button.
Both functions are useful. Your choice should depend on the task,
the data source, and the validation rules your app needs.
When Should You Use SubmitForm?
Choose SubmitForm()
when your app uses a standard form and you want Power Apps to manage the
submission process.
It works well for:
·
Employee registration forms.
·
Leave request applications.
·
Customer feedback forms.
·
Contact information updates.
·
Simple data entry applications.
It is also useful when you need form-level validation and want to
handle success and failure through the form's properties.
However, form validation does not replace every business rule. You
may still need extra checks for duplicate records, date ranges,
permissions, or other requirements.
When Should You Use Patch?
Choose Patch()
when you need greater control over the records or fields you want to save.
It is useful for:
·
Updating one field in a record.
·
Creating records from custom
controls.
·
Changing task status from a
gallery.
·
Saving selected values without a
standard form.
·
Updating several fields in an
existing record.
For example, a help desk app may show a list of support tickets.
When an employee clicks a button to mark a ticket as resolved, Patch() can update
the ticket's status.
This avoids the need to submit an entire edit form for a small
change.
Developers working with Power Apps And Power Automate Training
can practise both methods and learn how saved records can support business
workflows.
Common Mistakes to Avoid
One common mistake is updating the wrong record. When using Patch(), check that
the record reference identifies the correct item. Test your formula with sample
records before using it with real data.
Another mistake is assuming that Patch() performs the same validation as a form. It
does not automatically run the full form validation process. Add the checks
your application needs.
With SubmitForm(),
make sure the form is connected to the correct data source. Also check its
mode. New mode is used to create a record, while Edit mode is used to update an
existing record.
Finally, handle errors carefully. Saving may fail because of
missing required fields, incorrect values, insufficient permissions, or
connection problems. Use suitable error messages and test both successful and
unsuccessful submissions.
Frequently Asked Questions
Q1. Is Patch better than SubmitForm in Power Apps?
A: Neither is always better. SubmitForm() is
suitable for standard forms, while Patch() offers more control over individual records
and fields.
Q2. Can Patch create a new record?
A: Yes. Use Patch() with Defaults() for the
relevant data source to create a new record.
Q3. Can SubmitForm update an existing record?
A: Yes. Put the form in Edit mode,
set its Item
property to the correct record, and submit the form.
Q4. Does Patch validate all form fields automatically?
A: No. You must add the validation
checks required by your app and handle errors properly.
Q5. Can I use Patch and SubmitForm in the same app?
A: Yes. You can use SubmitForm() for
standard forms and Patch()
for actions such as updating a task status.
Conclusion
Patch() and SubmitForm() both help you save data in Power Apps, but each method serves a
different purpose. SubmitForm()
is a practical choice for standard forms because it works with form validation
and submission settings. Patch() is useful when you need to create records,
update selected fields, or save information from custom controls. Understanding
these differences helps you choose the right method for each task.
The best way to learn is to build a small application and test
both functions. Start with an employee registration form using SubmitForm(). Then
create a task list that uses Patch() to update task 0073tatus. Test the results,
check error messages, and confirm that the correct records are saved. With
regular practice, you can build reliable apps that meet real business needs.
Trending
Courses: Azure Data Engineering, Azure AI, SAP UI5 Fiori, SAP BTP CAP with Fiori.
Visualpath
is
the Leading and Best Software Online Training Institute in Hyderabad.
For More Information about Best Microsoft Power Apps
Contact Call/WhatsApp: +91-7032290546
Visit: https://www.visualpath.in/microsoft-powerapps-training.html

Comments
Post a Comment