web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collection duplicating...
Power Apps
Unanswered

Collection duplicating item.. SaveData function

(1) ShareShare
ReportReport
Posted on by 1,257 Super User 2024 Season 1

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?

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at

    Ignore !! Soon as I posted this I realised my error in not clearing the collection before loading it..

  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard