How do I create an edit form, and new form
from a gallery based on a SQL view
I understand I can use patch to submit the data to multiple tables once the edit/new form is configured
please and thank you
Jese

How do I create an edit form, and new form
from a gallery based on a SQL view
I understand I can use patch to submit the data to multiple tables once the edit/new form is configured
please and thank you
Jese
Hi @jesenavaranjan,
Could you please share a bit more about your scenario?
Do you want to patch form data into your SQL View or these base tables your SQL View based on?
If you want to patch form data into your SQL View directly, I afraid that there is no way to achieve your needs in PowerApps currently.
The SQL View data sources are read-only in PowerApps currently, we could not patch any data into the SQL View from an app. But as an alternative solution, you could patch form data into the base tables (which your SQL View relies on) based on the primary key columns in your SQL View.
Please check the following blog for more details:
https://powerapps.microsoft.com/en-us/blog/using-sql-server-views-in-powerapps/
If you want to patch form data into your base tables your SQL View relies on, I think the Patch function could achieve your needs.
Firstly, you need to add your base SQL tables as data source into your app. Then add a Edit form control within your app, set the DataSource property of the Edit form to one SQL Table. Set the Item property of the Edit form to following:
LookUp('[dbo].[Employees]', Id = BrowseGallery1.Selected.Id)
On your side, you should type:
LookUp('[dbo].[BaseTable]', PrimaryColumn = BrowseGallery1.Selected.PrimaryColumn)
Note: The PrimaryColumn represents the Primary Key column in your base table, the PrimaryColumn represents the Primary Key column in your SQL View, which also referenced from the PrimaryColunn in your base table.
If you want to edit an existing record in your base tables based on the selected SQL View record in the Gallery, please take a try with the following formula:
Patch(
'[dbo].[BaseTable]',
LookUp('[dbo].[BaseTable]', PrimaryColumn = BrowseGallery1.Selected.PrimaryColumn),
EditForm1.Updates /* <-- EditForm1 represents the Edit form control */
)
Or
Patch(
'[dbo].[BaseTable]',
LookUp('[dbo].[BaseTable]', PrimaryColumn = BrowseGallery1.Selected.PrimaryColumn),
{
Column1: DataCardValue1.Text,
Column2: DataCardValue2.Text,
...
}
)
If you want to add a new record into your base tables, please take a try with the following formula:
Patch(
'[dbo].[BaseTable]',
Defaults('[dbo].[BaseTable]'),
EditForm1.Updates /* <-- EditForm1 represents the Edit form control */
)
Best regards,
Kris