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

Patching Sharepoint list with gallery input boxes

Hi all,

I have a problem with patching a Sharepoint list with data from a gallery in my Powerapp.

 

So first of all I am not sure if I am using my gallery setup correctly. This is what the gallery looks like (it's basically a table):

image.png

 

 

 

 

 

The gallery has two input text fields and two input date pickers. The "plus" button adds another row of input fields to the gallery. 

It works like this: 

1. On app start I do "ClearCollect(timelineCollection,0);"

2. Gallery Items property is set to the timelineCollection

3. The "plus" button does: "Collect(timelineCollection, CountRows(timelineCollection))"

 

That way the timeline collection gets another number added to it which becomes another gallery item which adds another row to the gallery.

 

So my problem is the following: after adding a second row of data to the gallery, I can't reference the first row anymore!

When I do Gallery.Selected.InputField , it references the data from the latest input field that was added to the gallery. 
I am not aware of a way to reference the contents of the previous input fields that were first added to the gallery.

 

In the end, what I need is to patch a sharepoint list with all of the contents from the input fields to a, let's say text field with multiple lines. 

Is there a way to do this?

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @NSimpraga ,

Do you want to use a gallery to update sharepoint list?

Q1:reference the first row 

"Gallery.Selected.InputField" refers the last item that you select in the gallery.

Since you just entered a new row of  input field, so it will be latest input field.

To refer data in the first row, you just need to firstly click the first row.

Then "Gallery.Selected.InputField" will refer data of first row.

 

Q2:update sharepoint to a multiple line of text field by using this gallery

You just need to use Concatenate() function to connect data in four controls.

Try this:

ForAll(Gallery1.AllItems,
       Patch(listname,
             Defaults(listname),
             {multiplelineoftextfield:Concatenate(TextInput1.Text,",",
                                                   TextInput2.Text,",",
                                                   DatePicker1.SelectedDate,",",
                                                   DatePicker2.SelectedDate
                                                   )
               }
             )
        )

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

3 REPLIES 3
v-yutliu-msft
Community Support
Community Support

Hi @NSimpraga ,

Do you want to use a gallery to update sharepoint list?

Q1:reference the first row 

"Gallery.Selected.InputField" refers the last item that you select in the gallery.

Since you just entered a new row of  input field, so it will be latest input field.

To refer data in the first row, you just need to firstly click the first row.

Then "Gallery.Selected.InputField" will refer data of first row.

 

Q2:update sharepoint to a multiple line of text field by using this gallery

You just need to use Concatenate() function to connect data in four controls.

Try this:

ForAll(Gallery1.AllItems,
       Patch(listname,
             Defaults(listname),
             {multiplelineoftextfield:Concatenate(TextInput1.Text,",",
                                                   TextInput2.Text,",",
                                                   DatePicker1.SelectedDate,",",
                                                   DatePicker2.SelectedDate
                                                   )
               }
             )
        )

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

Thank you @v-yutliu-msft !


Yes, I want to update my Sharepoint list using data from my gallery items. Thing is, it's not the only data that will be used to update the list. I have multiple regular independent input fields/dropdowns that are static and outside the gallery, in the same Powerapp, which I can reference individually. This is how the whole app screen looks like:

image.png

 

But now I think I understand what is going on. My input text fields are gallery items which I can reference with the Allitems property. The idea is to populate all this data and with the submit, get all the data on the screen to a single record in Sharepoint.

 

Your code helped me, as in I managed to get the data from all the gallery items to Sharepoint, but it has two issues: 

1. The ForAll calls Patch every time for every item, therefore I have multiple records for every item in the gallery. I need to have all the items data stored in a single record. So all the entries from the Timeline / Key Milestones gallery should be stored in a single record.

2. I can't concatenate the dates because they are not of type Text.

 

It is a good start because now I know I can loop through all the items using the ForAll and Allitems, but I still need to format the data the way I want to.

 

Is there any other way to reference items individually in the gallery? Besides looping through them using ForAll?

NSimpraga
Helper I
Helper I

Just to update - I managed to solve the problem.

What I did was collect all the item data from the gallery with a ForAll into a collection after which I pass the whole collection column to the Concat function to concatenate the data with delimiters and then Patch it like that to the SP list with a delimiter between the entries.

 

Thanks @v-yutliu-msft once again for pointing me in the right direction!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (90,294)