Showing results for 
Search instead for 
Did you mean: 
Helper III
Helper III

Data from Gallery is not being saved to database once I close the app.

Hi Team,

I've used the below code to show the data in each boxes. It works well until I close the app and relaunch it.

Please see Pic 2. Seems like the 2nd row onwards does not save.



Pic 1 : 



Pic 2 : 



I've added the below code to "On Visible" so that it will save to my database the moment it opens the page : 


ForAll(Filter(GalleryLaptop.AllItems, Toggle1.Value = true), Patch(SUMMARY_LAPTOP, ThisRecord, {LUTONG:TextInput6_1.Text, 'MENARA SHELL':TextInput6_2.Text, 'PLAZA SHELL':TextInput6_3.Text, 'LABUAN SUPPLY BASE':TextInput6_4.Text, TOTAL:TextInput6_5.Text})) ;
ForAll(Filter(GalleryAccessories.AllItems, Toggle2.Value = true), Patch(SUMMARY_ACCESSORIES, ThisRecord, {LUTONG:TextInput11.Text, 'MENARA SHELL':TextInput11_1.Text, 'PLAZA SHELL':TextInput11_2.Text, 'LABUAN SUPPLY BASE':TextInput11_3.Text, TOTAL:TextInput11_4.Text}))


Please advise.


Thanks to @v-albai-msft for providing the solution for my initial issue :



Thank you!


Community Support
Community Support

Hi @vikna ,


Please provide more information.

What's Toggle1 ? I did not find it from the picture. Please provide the relevant formula and describe its usage.

What's Items  formula of  GalleryLaptop ?

What's Items  formula of  GalleryAccessories?

What's Items  formula of  Gallery1_1?

What's formula of LaptopModel?

What's formula of Laptops?


From the image, it seems that you are using nested galleries?

Please provide as much information as possible, such as what is each name you defined?


Best Regards,


Basically there is 4 Gallery for Laptop and another 4 for Accessories.

Total 4 locations 



Lutong : Gallery 1_1

Menara Shell :  : Gallery 1_2

Plaza Shell : Gallery1

Labuan Supply Base : Gallery1_3




Lutong : GalleryLUT

Menara Shell :  : GalleryKL

Plaza Shell : GalleryKK

Labuan Supply Base : GalleryLSB



What's Toggle1 ? I did not find it from the picture. Please provide the relevant formula and describe its usage.
It is hidden. Purpose is to tell if there is any changes done on the box .

Formula :
ThisItem.LUTONG <> TextInput6_1.Text Or ThisItem.'MENARA SHELL' <> TextInput6_2.Text Or ThisItem.'PLAZA SHELL' <> TextInput6_3.Text Or ThisItem.'LABUAN SUPPLY BASE' <> TextInput6_4.Text Or ThisItem.TOTAL <> TextInput6_5.Text





What's Items formula of GalleryLaptop ?
TextInput6_1 : LookUp(Gallery1_1.AllItems,LaptopModel.Text = Laptops.Text).Total.Text
TextInput6_2 : LookUp(Gallery1_2.AllItems,LaptopModelKL.Text=Laptops.Text).TotalKL.Text
TextInput6_3 : LookUp(Gallery1.AllItems,LaptopModelKK.Text=Laptops.Text).TotalKK.Text
TextInput6_4 : LookUp(Gallery1_3.AllItems,LaptopModelLSb.Text=Laptops.Text).TotalLSB.Text
TextInput6_5 : TextInput6_1 + TextInput6_2 + TextInput6_3 + TextInput6_4

What's Items formula of GalleryAccessories?
TextInput11 : LookUp(GalleryLUT.AllItems,ProductsLUT.Text = Accessories.Text).QuantityLUT.Text
TextInput11_1 : LookUp(GalleryKL.AllItems,ProductsKL.Text = Accessories.Text).QuantityKL.Text
TextInput11_2 : LookUp(GalleryKK.AllItems,ProductsKK.Text = Accessories.Text).QuantityKK.Text
TextInput11_3 : LookUp(GalleryLSB.AllItems,ProductsLSB.Text = Accessories.Text).QuantityLSB.Text
TextInput11_4 : TextInput11.Text + TextInput11_1.Text + TextInput11_2.Text + TextInput11_3.Text

Toggle 2 :
ThisItem.LUTONG <> TextInput11.Text Or ThisItem.'MENARA SHELL' <> TextInput11_1.Text Or ThisItem.'PLAZA SHELL' <> TextInput11_2.Text Or ThisItem.'LABUAN SUPPLY BASE' <> TextInput11_3.Text Or ThisItem.TOTAL <> TextInput11_4.Text

What's Items formula of Gallery1_1?
no specific formula. Its connected to a data source (Excel) when I hit the update button


Update button formula : (toggle is hidden)
ForAll(Filter(Gallery1_1.AllItems, Toggle3_1.Value = true) , Patch(LUT_LAPTOP, ThisRecord, {JML:TextInput1_8.Text, CAR:TextInput1_9.Text, SECONDEE:TextInput1_10.Text , BREAKFIX:TextInput1_11.Text,VIP:TextInput1_12.Text, TOTAL:Total.Text}))


What's formula of LaptopModel?
What's formula of Laptops?
This is based on @v-albai-msft advise in my previous post :


I hope this explains better. hopefully not too much useless information. I'm still new to Powerapp 🙂





Community Support
Community Support

Hi @vikna ,


Thanks for your supplement.


I have the following questions:

1\ I see that you have 3 loop patch functions, which one failed to execute? Please see the picture below




2\ Could you add a description of the problem you encountered?  Did you run it for the first time without problems?

Did you open the app for the second time and it didn't work properly?

Your formula has no grammatical errors, so I want to know what you want to achieve.


3\ Thank you for the supplementary explanation of many textinput controls  .But I also want to know the Items property of your gallery 'GalleryLaptop ' and 'GalleryAccessories'. 




4\ What is your data source? How many data sources do you have? 

From your formula, I can see that you have three loop patch formulas, so do you have 3 data sources and do you want to modify their records?


Best Regards,



1.  All 3 did not fail to execute. There are no errors generated



a. This is the main page which have 2 dropdown

Location :


Menara Shell

Plaza Shell




Items :






b. After selecting the dropdowns, I click on EDIT.


c. I have 2 more screens for each of the 4 location mentioned before each similar as below.





d. This is the summary page.

If I open the app, and then update laptop and accessories inventories from the page above, it updates the summary screen properly.



e. However, I close the app and then launch it again, it will be something similar as below.

The only this that stays are the details for HP EliteBook 830 (G5,G6,G7) AND USB Standard Keyboard ALL.



f. At the launch of SUMMARY page (On Visible) , the below formula will be applied to ensure it saves to my database.


And it saves in the Excel database.

However, upon closing my application, those details are missing




g. And all data in my other screen is retained. Only SUMMARY page is having issues.



I want to ensure that the details captured in the SUMMARY pages does not go missing.



3. The Item formula for GalleryLaptop and GalleryAccessories.






4.  These are my data sources using Excel file location in One Drive.



The output in Excel should be like below for each location (WORKS FINE) and one page of summary(NOT WORKING) : 




Community Support
Community Support

Hi @vikna ,


Sorry, your data structure and app are very complicated.

I don't have any good suggestions.

Hope someone can help you.


Best Regards,


thanks for your advise so far.


hopefully someone would be able to advice.

Helpful resources

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!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,660)