Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

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?

 

 

 

  • mmbr1606 Profile Picture
    12,108 Super User 2025 Season 1 on at
    Re: Collection duplicating item.. SaveData function

    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

  • Verified answer
    vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at
    Re: Collection duplicating item.. SaveData function

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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard