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 Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,328)