cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Elitezone
Post Prodigy
Post Prodigy

Multiple data save (not just one last input)

Hello,

 

I have this code:

If(

    !IsBlank(

        LookUp(

            Obrazy_obecnosc,

            Last(

                Split(

                    'Imię i nazwisko'.Claims,

                    "|"

                )

            ).Result = Lower(User().Email) && DateValue(Text(Created)) = Today()

        )

    ),

    Patch(

        Obrazy_obecnosc,

        LookUp(

            Obrazy_obecnosc,

            Last(

                Split(

                    'Imię i nazwisko'.Claims,

                    "|"

                )

            ).Result = Lower(User().Email) && DateValue(Text(Created)) = Today()

        ),

        {

            Nazwa_zadania: Zadanie_nazwa.Text,

            Opis_zadania: Zadanie_opis.Text

        }

    )

)

It saves data from inputboxes Nazwa_zadania and Opis_zadania to my Sharepoint list.

But it saves only one record.

 

My inputbox is in gallery and I can fill for example 10 such input boxes, but only last one will be saved.

I would like to save all data that is filled.

 

Is it possible?

Is it possible to save all input boxes?

1 ACCEPTED SOLUTION

Accepted Solutions

@Elitezone ,

@RandyHayes 's extrapolation of the code you supplied to add all items in the gallery is correct syntax based on what you posted, but I think I can see a flaw in the logic - you are saying if the record is not found, then Patch to that record (which does not exist). This may be what you are after

ForAll(
   yourGallery.AllItems,
   With(
      {
         record: 
         LookUp(
            Obrazy_obecnosc, 
            Lower('Imię i nazwisko'.Email) = Lower(User().Email) && 
            Text(Created, ShortDate) = Text(Today(), ShortDate)
         )
      },
      If(
         !IsBlank(record),
         Patch(
            Obrazy_obecnosc,
            Defaults(Obrazy_obecnosc),
            {
               'Imię i nazwisko'.Email:Lower(User().Email),
               Nazwa_zadania: Zadanie_nazwa.Text,
               Opis_zadania: Zadanie_opis.Text
            }
         )
      ) 
   )    
) 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

6 REPLIES 6
rebeccas
Community Champion
Community Champion

If I am understanding what you are needing correctly you need to use ForAll. You have multiple items in a gallery and want each line item to create a line item on your SharePoint List (or whatever data source you have). An example of how you would use this is:

 

ForAll(Gallery1.AllItems,
Patch(SPList, Defaults(SPList),
{Title: val_Title.Text,
{Column2: val_Name.Text}))

 

The Title and Column2 above would be the column names on your SharePoint list and the val_Title and val_Name would be labels with values in your gallery. 

 

I don't typically do it straight from a gallery. I use a collection. When they select an item it goes into collection, gallery displays items in collection and my Patch looks to the collection for the values (instead of directly to gallery). But it can work either way.

 

Hope this helps!

RandyHayes
Super User
Super User

@Elitezone 

Since you are pulling this information from the Gallery (which is already a collection), you need to simply perform your Patch function For All of the records in the collection.

This formula would be what you are looking for:

ForAll(yourGallery.AllItems,
    With({record: LookUp(Obrazy_obecnosc, Lower('Imię i nazwisko'.Email) = Lower(User().Email) && Text(Created, ShortDate)) = Text(Today(), ShortDate))},
        If(!IsBlank(record),
            Patch(Obrazy_obecnosc,
                record,
                {
                    Nazwa_zadania: Zadanie_nazwa.Text,
                    Opis_zadania: Zadanie_opis.Text
                }
            )
        )
    )    
)    

Note: I noticed you were comparing the email address on the Imię i nazwisko column by splitting the claims column, you can reduce that overhead by just comparing the Email column as shown in the above formula.

Also, your date comparison may run into issues how you had it, so it is adjusted in the above formula.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you, but it is not working 😞

 

I think that at the end there is one additional ).

Also it shows Invalid number of arguments received 1 expected 2 in With(records).

Also errors The function for all has some invalid arguments and unexpected characters.

RandyHayes
Super User
Super User

@Elitezone 

Please scrub through the formulas I provide as I type them by hand without the aide of a design editor.

There was an extra paren in the formula.  Change to the following (still might be some typos):

ForAll(yourGallery.AllItems,
    With({record: LookUp(Obrazy_obecnosc, Lower('Imię i nazwisko'.Email) = Lower(User().Email) && Text(Created, ShortDate) = Text(Today(), ShortDate))},
        If(!IsBlank(record),
            Patch(Obrazy_obecnosc,
                record,
                {
                    Nazwa_zadania: Zadanie_nazwa.Text,
                    Opis_zadania: Zadanie_opis.Text
                }
            )
        )
    )    
)    
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

I cannot even test it 😞

 

When I had collection I could use command Collect to create new blank item in Gallery.

But when I switched to sharepoint list style new item is not created, and I do not know how to manage it.

 

My gallery has input box in it, and I want to make more empty boxes when I click a button.

@Elitezone ,

@RandyHayes 's extrapolation of the code you supplied to add all items in the gallery is correct syntax based on what you posted, but I think I can see a flaw in the logic - you are saying if the record is not found, then Patch to that record (which does not exist). This may be what you are after

ForAll(
   yourGallery.AllItems,
   With(
      {
         record: 
         LookUp(
            Obrazy_obecnosc, 
            Lower('Imię i nazwisko'.Email) = Lower(User().Email) && 
            Text(Created, ShortDate) = Text(Today(), ShortDate)
         )
      },
      If(
         !IsBlank(record),
         Patch(
            Obrazy_obecnosc,
            Defaults(Obrazy_obecnosc),
            {
               'Imię i nazwisko'.Email:Lower(User().Email),
               Nazwa_zadania: Zadanie_nazwa.Text,
               Opis_zadania: Zadanie_opis.Text
            }
         )
      ) 
   )    
) 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

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.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

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
Top Kudoed Authors
Users online (3,659)