Bhubaneswar, Odisha, India
+91-8328865778
support@softchief.com

Create or Update records without using Forms in Canvas Apps using Patch function

Create or Update records without using Forms in Canvas Apps using Patch function

When we build canvas apps in Power Apps, we add Galleries to display records from our data source and Forms to view, create, and edit individual records, but sometimes forms are not enough to achieve our business scenarios. For those scenarios, We use Power Apps functions for updating tabular data sources directly.

Patch is used when you want to update data source directly without using forms. Lets take a scenario. For example you want to update a log table data source every time a user clicks a button to navigate to another screen you could use the formula for the OnSelect property of the button.

The below is the table with two fields.

The Canvas Apps is connected to table and created two screens with one buttons. When the user is on main screen and after filling the contact details and clicking Next button to go second screen I want to log some information so we have to call Patch function as below. Call the function on Select property.

The below Power FX can be used to create record.

Patch('Log Tables', Defaults('Log Tables'), {'Clicked User': User().FullName, 'Clicked Time': Now()}); 
Navigate(secondscreen, ScreenTransition.Cover)

Now you will see the details saved in table.

To Edit or Update Record you can use below formula:

Patch(Orders, LookUP(Orders, ID = 1), {Region: "Asia", Country: "China"})

Update all records using below formula

Patch(CustomerOrders, Default(CustomerOrders), {Status: "Pending"})

Delete Record:

Remove(CustomerOrders, LookUp(CustomerOrders, ID = 1))

Delete Based on Condition

RemoveIf(CustomerOrders, Status = “Expired”)

Delete Records of a Collection:

Clear(collectSelectedItems)

Conditional Delete

RemoveIf(CustomerOrders, true)

Hope this helps

Follow my blog for more trending topics on Dynamics 365, Azure, C#, Power Portals and Power Platform. For training, Courses and consulting, call to us at +91 832 886 5778 I am working more for community to share skills in Dynamics 365 and Power Platform. Please support me by subscribing my YouTube Channel. My YouTube Channel link is this : https://www.youtube.com/user/sppmaestro

You can enroll now !We are giving 30% discount on our Internship Program

Don’t miss the chance to participate in the upcoming Internship Program which will be done using Microsoft Dot Net Web Development Full Stack Technology. The new batch will be starting from May 20, 2024.  We will have most experienced trainers for you to successfully complete the internship with live project experience.

Why to choose Our Internship Program?

Industry-Relevant Projects
Tailored Assignments: We offer projects that align with your academic background and career aspirations.
Real-World Challenges: Tackle industry-specific problems and contribute to meaningful projects that make a difference.

Professional Mentorship
Guidance from Experts: Benefit from one-on-one mentorship from seasoned professionals in your field.
Career Development Workshops: Participate in workshops that focus on resume building, interview skills, and career planning.

Networking Opportunities
Connect with Industry Leaders: Build relationships with professionals and expand your professional network.
Peer Interaction: Collaborate with fellow interns and exchange ideas, fostering a supportive and collaborative environment.

Skill Enhancement
Hands-On Experience: Gain practical skills and learn new technologies through project-based learning.
Soft Skills Development: Enhance communication, teamwork, and problem-solving skills essential for career success.

Free Demo Class Available