cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sanrajbhar
Helper I
Helper I

Patch the Existing filtered records on EditForm - dealing with many-to-many

I am creating form to have functionalities - search , edit , new records. I am using many to many table in Azure SQL.

My Data looks:

 

A_tbl

[A_id:1,A_id:2,A_id:3]

  - My main table

 

 

Bridge_tbl

{A_id:1,B_ID:1},{A_id:1,B_ID:2},{A_id:1,B_ID:4}

 

 

B_tbl

{B_id:1, nameid:”1”}, {B_id:2, nameid:”2”}, {B_id:3, nameid:”3”}, {B_id:3, nameid:”4”}

 

 

Another tble for nameid/name

 

Name_tbl

{ nameid:”1”, name:”Alex”}, { nameid:”2”, name:”Ian”}, { nameid:”3”, name:”Kali”}, { nameid:”4”, name:”Kate”}

 

 

My gallery item is having view from A_tbl, Bridge_tbl, Name_tbl  and retrieve the [name] rather using two lookup  which is works but too slow so utilizing view. Lets call it View_Gall_tbl.

 

When I clicked on item on gallery  - I can then show from A_tbl (using lookup in item = LookUp(View_Gall_tbl, ID = gall_app.Selected.appID)

 

So I can ViewForm with A_tble information with  [name].

What I need now -  On Edit form Mode – Patch this

 

From

 

A_id = 1    ->  B_id = 1,2,4   -Multiples records in AzureSQL

 

 

To - adding one more related item

 

A_id = 1 ,    ->  B_id = 1,2,4,3  

 Patched Kali as name in bride tble - A_ID = 1 , 

 

 

 

I am using combo box for [name] and retrieving related stuff – the related name has been comma joined in my view.

 

Sorry for confusing long question. maybe rephrase seeing responses.

1 ACCEPTED SOLUTION

Accepted Solutions
v-micsh-msft
Community Support
Community Support

So the current situation here is:

A_tbl is configured as the data source of the View form control, and based on the selection, you would like to update the bridge_tbl with one additional record, right?

 

If this is the case, then there is no need to take use of an EditFrom control, we could just take use of some controls to make it work.

The control that we need should be:

1. Navigate button,

2. Combo Box control for the B_tbl to hold the values for the NameId.

3. Display the confirmation of the data need to be submitted.

4. A Button to update the changes, using patch ().

 

Things to take a note:

A table which works in PowerApps should have Primary key defined, assuming here Bridge_tbl has a auto-generated primary key field, then the Patch function should be written as below:

patch(Bridge_tbl, defaults(Bridge_tbl), {A_id:Gallery.Selected.appID, nameid:First(ComboBox.SelectedItems).nameid})

If I understand the table structure correctly.

 

Regards,

Michael

 

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-micsh-msft
Community Support
Community Support

So the current situation here is:

A_tbl is configured as the data source of the View form control, and based on the selection, you would like to update the bridge_tbl with one additional record, right?

 

If this is the case, then there is no need to take use of an EditFrom control, we could just take use of some controls to make it work.

The control that we need should be:

1. Navigate button,

2. Combo Box control for the B_tbl to hold the values for the NameId.

3. Display the confirmation of the data need to be submitted.

4. A Button to update the changes, using patch ().

 

Things to take a note:

A table which works in PowerApps should have Primary key defined, assuming here Bridge_tbl has a auto-generated primary key field, then the Patch function should be written as below:

patch(Bridge_tbl, defaults(Bridge_tbl), {A_id:Gallery.Selected.appID, nameid:First(ComboBox.SelectedItems).nameid})

If I understand the table structure correctly.

 

Regards,

Michael

 

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,751)