cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alanisp22
Helper II
Helper II

Forall Gallery Items Patch to SP List Not Working

Hello,

 

I have been trying to figure out why my gallery items are no longer patching to a new SharePoint list. It's starting to drive me crazy... I am using the expression below but nothing is being created in my new SharePoint list. Any idea why it's no longer working?

 

Information about my gallery:
I am using one combo box and three input fields to collection (using the 'Onselect' on a button) information into a collection on my SharePoint form. Then I have my gallery added within a datacard to default all the collection items within input text fields. When I test the form the gallery is displaying as expected, but when I submit it nothing is being created (patched) to the new SharePoint list. I added my gallery into an existing datacard so it wouldnt move and overlap with the other cards when a user scrolls through the form.

 

Expression I am using within the 'OnSuccess' of my form. 

ForAll(Gallery.Allitems,Patch(SPlist,Defaults(SPlist),{Title: Titleinputfield.text}));ResetForm(Self);RequestHide()

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Alanisp22 ,

Firstly, you might watch this video from Shane Young @Shanescows and ask yourself why you need the Lookup columns - I have not used them in years.
Assuming your fields are names the same in the collection and the list, this may work

ForAll(
   ServiceCollection As aService,
   Patch(
      Services,
      Defaults(Services),
      {
         Title:"Hello",
         Received:Value(aService.ReceivedUnits),
         Completed:Value(aService.CompletedUnits),
         Price:Value(aService.Price),
         ExpectedAmount:Value(aService.ExpectedAmount),
         ActualAmount:Value(aService.ActualAmount),
         Service:
         {
            '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",            
            Value:aService.Service.Value,
            Id:aService.Service.Id
         },
         Account:
         { 
            '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
            Value:aService.Account.Value,
            Id:aService.Account.Id
         },
         InvoiceID:SharePointForm1.LastSubmit.ID
      }
   )
);
ResetForm(Self);
RequestHide();
Reset(Gallery)

 

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

19 REPLIES 19
WarrenBelz
Super User III
Super User III

Hi @Alanisp22 ,

Is TitleInputField in the gallery? If so you need to refer to the actual field name (not the control) and you do not need the .Text reference. If not in the gallery, there is nothing to Patch in the ForAll.

 

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.

 

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.

Hi @WarrenBelz ,

Yes, TitleInputfield is in the gallery. That is the name of the input field that holds the text I need to patch to my Sharepoint list. I removed the .text but that still didn't work. Do you think having my gallery in a Datacard is the issue? 

Hi @Alanisp22 ,

What are the Items of the gallery and how do they relate to the Item of your Form?

Hey @WarrenBelz,

I have 1 drop-down column and 3 input text fields in my gallery. Above the gallery, I have 1 combo drop-down box that allows a user to select a service from choices (pulled from my 1st SP list titled 'Pricing') and  3 input text fields where the user would input the quantity received, quantity expected, and price. From there, they would click on a button to add these details to a collection titled 'ServiceDetails'. The gallery is then set to display this collection by having its items set to 'ServiceDetails'. The gallery consists of one drop-down and 3 text input fields, which display the collection details. I have the gallery's drop-down default set to 'This Item.Servicename' (to reflect the service name selected), 2nd text input default set to 'This item.QuanityRvd', 3rd text input set to 'ThisItem.Competed' and the final text input default on the gallery is set to 'This Item.Price'.  The gallery is working as expected by displaying each item added to the collection, I just can't get it to patch to a new SharePoint list. The other issue I just noticed is that the gallery is no longer displaying any items when a user opens a previously submitted form to edit it. Could this be related to the reason why my items are not patching to a new SharePoint list?

 

Hi @Alanisp22 ,

Firstly trying to bulk-patch gallery edited items has a lot of challenges including "unbound" controls resetting unless you patch them at the time to gallery-connected fields (and this is also connected to your problem).

Have you considered simply patching each line item as they are modified?

 

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.

@WarrenBelz, If I patch them as they are modified, how would that affect new forms with line items added to the gallery that do not need modifications? For example, if a user opens a new form adds services to the gallery and then makes modifications to them prior to submitting the form and then cancels without saving the form, will that still create each line item in the new SharePoint list? If so, is there a way for them to be removed if the form is canceled (not submitted)? 

@Alanisp22 ,

I cannot see your model, but from what you describe, you could simply deleted any record not required from the collection. If a new line is created, an icon (trash can?) in the gallery with

Remove(
    YourCollection,
    ThisItem
)

will allow the user to delete it. You could make the Visible on the icon

ThisItem.IsSelected

plus any other criteria that identifies it is a new record.

 

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.

 

Hi @Alanisp22 ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

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.

Hi @warren , I got the patch to go through (to the new SharePoint list) by patching the collection rather than the gallery. What are your thoughts on this approach? Also, I used the Remove(collectioname, ThisItem) you provided and it worked. Thank you for that.

 

I just now need to figure out two things. How to get the gallery to show the items submitted in each form when editing (right now my gallery is completely blank when a user opens a previously submitted form to edit it) and how to get my form to recognize if something was removed from the gallery, to delete it's listing from the new SharePoint list it was previously patched to. 

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

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (59,083)