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

Gallery Collection Items Disappearing When Form Submitted

Hello,

 

I have a SharePoint form consisting of two screens. The first screen is connected to my SharePoint list "Service Tracker" columns and the second screen consists of text (pulled from screen one data), a drop-down menu for service options, and 3 input fields. Once a user selects a service from the drop-down and then inputs values into the 3 input fields they are added to a collection by clicking on the 'Add Service' button.

The collection items are then listed in the inserted gallery displayed below. The gallery's "Items" is set to my collection name "ServiceCollection", and Upon submission of the form ( once the screen once is filled in and screen two has services added to it) the gallery items are patched to a second SharePoint list "Services".  My issue is that once a user goes back to the previously submitted form to make edits the gallery is completely blank. I need the gallery to display all the previously added services in case a user needs to edit them, delete, or add more. I do see that the patching of these services is working correctly but they are just not appearing in the gallery after submission. Does anyone have a suggestion on how to resolve this?

Additional note, each service added to the gallery is patched to my second SP list "Services" with the ID number of the submitted form to tie them together for reporting.

Gallery items are appearing as expected when the form is being completed:

Alanisp22_2-1607103936676.png

 

 

Gallery is completely blank in the view and edit mode once the form is submitted: 

Alanisp22_3-1607103963311.png

 

 


It appears my collection is being cleared as soon as the form is submitted but I am not sure why. 

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks @Alanisp22 ,

Please click Accept as solution as my post helped you solve your issue.

This will help others find it more readily.

It also closes the item. 

View solution in original post

17 REPLIES 17
WarrenBelz
Super User
Super User

HI @Alanisp22 ,

A collection does not "clear" by itself - there must be something in your submit code that is doing this.

How do you make ServiceCollection and when and what is your code on submit?

Hi @WarrenBelz, the ServiceCollection is created by clicking on the 'Add service' button. I have the following function in the "OnSelect" of the button:

  "Collect(ServiceCollection,{Account:Clientselected.Selected.Value,AccountId:Clientselected.Selected.Id,ServiceName:Servicebox.Selected.Value,ServiceId:Servicebox.Selected.Id,ReceivedUnits:Receivedunitinput.Text,CompletedUnits:Completeunitinput.Text,Price:Value(PricePerUnitInput.Text),ExpectedAmount:Value(Receivedunitinput.Text)*Value(PricePerUnitInput.Text),ActualAmount:Value(Completeunitinput.Text)*Value(PricePerUnitInput.Text)});Reset(Receivedunitinput);Reset(Completeunitinput);Reset(PricePerUnitInput);Reset(Servicebox)" . 

I then have the gallery's items set to: ServiceCollection, and each drop-down box (1st one in gallery) and input boxes set to the appropriate item in the collection using ThisItem.[Name of collection field] to display the data in the gallery. 

 

Upon clicking "Save" on the form in SharePoint (SP list name "ProjectTracker",  the items in the gallery are patched to my SharePoint list "Services" as expected. You helped me with this one. Thanks again! 🙂 But now the gallery is cleared when the user attempts to reopen the submitted form to make edits to the items in the gallery. I did have Reset(Gallery) in the "Onsuccess" code (listed on the form) but removed it and that did not resolve the issue. Here is the code I have listed in the "Onsuccess" field for my form.   "ForAll(Gallery.AllItems,Patch(Services,Defaults(Services),{Received:Value(Received.Text),Completed:Value(Completed.Text),Price:Value(Price.Text), ExpectedAmount:Value(ExpectedAmount.Text), ActualAmount:Value(ActualAmount.Text),InvoiceID:SharePointForm1.LastSubmit.ID, Service:
{
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Value:Service.Selected.Value,
Id:Service.Selected.Id
},Account:
{
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Value:Account.Selected.Value,
Id:Accounts.Selected.Id
}
}));ResetForm(Self);RequestHide()"

Hi @Alanisp22 ,

Firstly, why are you patching after already submitting the form - is this to a different list? That aside if the Patch works, leave it as it is. 

More importantly, there is nothing in there that would clear the ServiceCollection. Put a label on the screen with CountRows(ServiceCollection) and see what the number is when the gallery "goes blank".

 

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, yes, the items displayed in the gallery are being patched to a different list.

 

I added CountRows(ServiceCollection) and it counted the gallery items, as expected, but then once I submitted the form and reopened, it reflected "0" with the blank gallery. So it appears my collection is being cleared somehow once I submit the form. 

@Alanisp22 ,

Yes - that was what I was trying to establish (whether the issue was the collection or the gallery).

A collection does not clear by itself. Your collect function in the first part would only add more rows if run in error.

Which brings me to this comment submitted the form and reopened - what do you mean by re-opened?

 

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 , what I mean is that the form is filled out and then submitted (“saved”). The user then goes back to the submitted form (by editing the listing in 1st SP list) to made edits to any of the added services in the gallery. 

Hi @Alanisp22 ,

Can you please trace all code from the submission until the step you mention. A collection does not clear itself - there has to be code somewhere there that is doing this. For instance what happens at gallery OnSelect when the user chooses the 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 @WarrenBelz , I could not narrow down any code that clears it but I went back to your previous response in my patch issue and used the filter function you mentioned and that worked for me.  The "workaround" that I did was create a 2nd screen with another gallery that has the filter function you provided (set to pull all services with the ID number linked to the form) and set it so it's only visible in edit mode. You have helped me sooo much! I sincerely appreciate it!!

Thanks @Alanisp22 ,

Please click Accept as solution as my post helped you solve your issue.

This will help others find it more readily.

It also closes the item. 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,792)