Canvas app:

In this blog , I will show how to use single form for both edit & New in canvas app power apps. 

Step 1:

First open your Canvas app

Create a new screen

Canvas app

Add gallery and connect it to your data source like sharepoint , dataverse , excel etc,.

Add two buttons and rename them as New and Edit

Add another screen and add edit form .Connect it to the data source .

Now , Onselect property of Edit button write the code :

Set(varSelectedRecord, ThisItem);
Navigate(Screen3);
 
where ,
Screen3 = screen name

Now , Onselect property of New button write the code :

Navigate(Screen3);
NewForm(Form2)

 

In Form , select Defaultmode property and write as shown below:

If(IsBlank(varSelectedRecord),FormMode.New,FormMode.Edit)
Screenshot 2024-09-20 152124

Add a button in form page for saving the changes and name it as submit and Write code in Onselect property of that button as shown below:

SubmitForm(Form2);
Navigate(Screen2)

Now, it is working as expected .

For any Help or Queries Contact us on info@crmonce.com or +91 8096556344