I have a mobile app designed for offline use.
On Screen 1 I have a gallery with some items each of which has an ID. When I click a button in the gallery it sets the ID to a variable and navigates to a screen where I can upload images call it Screen 2
On Screen 2 here is the code I use on the OnSelect of a button after an image is uploaded
Collect(
mycolImages,
{
AttachmentID: lblID.Text,
Image: UploadedPhoto.Image,
TimeStamp: Now()
}
);
SaveData(
mycolImages,
"LocalmycolImages"
);
I also then have a gallery on Screen 2 which shows those images filtered by the matching ID and sorted by the timestamp.
That all works well
I then have another button that just navigates me back to screen 1 and on screen 1 I have a label which counts how many images are uploaded for that ID in the gallery (it counts rows in the collection)
This all works absolutely fine.
on the onvisible property of Screen 1 I get it to load the saved collection into local collection in case offline
LoadData(
mycolImages,
"myLocalImages",
true
))
In studio play mode on browswer because you can't save data it works fine but I think the SaveData must be causing an issue because if I use it on the device and say I upload 1 picture when I go back to Screen 1 it says there are 2 images if I then go to screen 2 yes there are 2 images in the gallery if I then go back to screen 1 it says there are now 3 images and if I go to screen 2 yes there are now 3 images in the gallery.. it keeps adding. So for example if I uploaded 2 images in the first place when I go back to screen 1 it says there are 4 and then 6 etc..
I'm completely stuck as to why the collection keeps duplicating? and why only on mobile even if not offline. The only places where the collect or the save data is as above.
Any ideas?
hey @vffdd
have u tried to clear the collection like this:
Clear(myLocalImages);
LoadData(
myLocalImages,
"LocalmycolImages",
true
);
Let me know if my answer helped solving your issue.
If it did please accept as solution and give it a thumbs up so we can help others in the community.
Greetings
Ignore !! Soon as I posted this I realised my error in not clearing the collection before loading it..
WarrenBelz
146,645
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional