cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gabrielv22
Level: Powered On

Multiple records associated with only one

Hi everyone

 

I need dev an app that i can generete various record, associated with only one.

For example, i need to input "title, date, category" and next i need input various "events, image" associated with "title, date, category".

 

In SQL have two tables. TableHead and TableBody.

The association is one to many.

 

TableHead:

  • id (key)
  • id_title (key associated)
  • title
  • date
  • category

TableBody:

  • id (key)
  • id_title (key associated)
  • event
  • image

I already know how to save records in SQL and I think I know how to associate them by generating the same "id_title (key associated)".

 

But I need to know how to make the power app allow me to add several "event and image" inputs as the user wants.

For example, a "+" button that adds new "event and image" fields that, when saved, are associated with the same tableHead table record.

".

2 REPLIES 2
Community Support Team
Community Support Team

Re: Multiple records associated with only one

Hi @gabrielv22 ,

Do you want to add multiple "event and image" fields via a "+" button, and saved with same tableHead table record?

 

Based on the needs that you mentioned, I think the Gallery control could achieve your needs. You could consider add a Gallery control within your app, and configure it as a Editable grid.

I think the repeating table sample app provided by @Shane Young would help in your scenario, please check the following video resources for more details:

https://www.youtube.com/watch?v=xgznk4XlPCo&t=66s

https://www.youtube.com/watch?v=DylxsXIUyDc&t=8s

https://www.youtube.com/watch?v=HUX_0AA4-Hs&t=1s

 

On your side, please consider take a try with the following workaround:

Set the OnStart property of the App to following:

ClearCollect(GalleryCollection, 1)

Add a Gallery control (Gallery1) within your app, set the Items property to following:

GalleryCollection

within the Gallery, add a Text Input box (EvenytTextInputBox) and a "Add Picture" control to collect your entry.

Outside this Gallery, add a "+" icon, set the OnSelect property to following:

Collect(GalleryCollection, CountRows(GalleryCollection)+1)

Add a Edit form (Form1) above the Gallery, then connect it to your TableHead SQL Table. Set the DefaultMode property of the Edit form to following:

FormMode.New

set the OnSelect property of the "Submit" button to following:

SubmitForm(Form1)

set the OnSuccess property of the Edit form to following:

ForAll(                                /* <-- Save multiple records from your Gallery back to your TableBody Table along with same "title, date, category" record */
          Gallery1.Allitems,
          Patch(
                 TableBodyTable,
Defaults(TableBodyTable),
{
id_title: Form1.LastSubmit.id_title,
event: EvenytTextInputBox.Text,
image: UploadedImage1.Image
} ) );
ResetForm(Form1)

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
gabrielv22
Level: Powered On

Re: Multiple records associated with only one

That worked!

 

Now, I have a problem with previewing the image.

Repeat the images in the gallery. But only when I am seeing them, because the correct ones are saved in the database.

 

Here I load the first image:

Image01.png

Here I try to load the second image but I repeat the previous one:

Image02.png

 

I need you to generate the record in the collection completely empty, with no image.

It also changes the text in the add image box. Change from "change image" (Image1) to "Add image" (Image2), when the image is already loaded.

 

I use this FX:

Patch(Col_TmpDetalleIns; ThisItem; {observacion: InputObs.Text; accion_tomada: InputAccion.Text; foto: UploadedImage1.Image});;
Collect(Col_TmpDetalleIns; {observacion: ""; accion_tomada: ""; foto: ""})

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,021)