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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / gallery getting reset ...
Power Apps
Answered

gallery getting reset to first item

(0) ShareShare
ReportReport
Posted on by 20

N/A

 

Categories:
I have the same question (0)
  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @azizqureshi1 - I think you have missed some key information in your description. Could you provide more detail on what you mean by "container". Also, please share screenshot of your app if possible.

  • azizqureshi1 Profile Picture
    20 on at

    N/a

  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @azizqureshi1 there are controls in Canvas Apps called "Containers", I suspect those are not what you mean.

     

    Despite the screenshot, I still do not understand what you mean by "container that has the controls on the screen."

     

  • azizqureshi1 Profile Picture
    20 on at

     

     

  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @azizqureshi1 I am struggling to understand your app with the information you have provided. 

     

    Remember, I do not know your app, I do not know what it looks like, I do not know what "OverViewMandatoryCount" is, I do not know why you have two Galleries in there inside a container, I do not know why you're using multiple containers etc etc

     

    Provide detail

     

  • azizqureshi1 Profile Picture
    20 on at

    Let me explain. I have a simple screen. The screen looks like the following:

    azizqureshi1_0-1695684341480.png

    The button 'Create Collection" has the following code:

    ClearCollect (
    col_Test,
             {
                Title: "Title 1",
                Index: 1,
                Number: 0
            },
            {
               Title: "Title 2",
               Index: 2,
               Number: 0
           },
          {
              Title: "Title 3",
              Index: 3,
              Number: 0
          }
    )

     

    The gallery Items property has the collection col_Test.

     

    The 'Update If' button has the following code:

     

    UpdateIf(
    col_Test,
         Index = 1,
        {Number: Rand()}
    );
    UpdateIf(
    col_Test,
        Index = 2,
        {Number: Rand()}
    );
    UpdateIf(
    col_Test,
        Index = 3,
        {Number: Rand()}
    )

     

    Now this is the issue. I have clicked on the second item in the gallery:

    azizqureshi1_1-1695688992856.png

    Now if I click the 'Update If' button. The Number field in the items gets updated, but the gallery selected item becomes the first item without me clicking the first item as shown below:

    azizqureshi1_2-1695689276714.png

    I want the gallery's selected item to remain the second item and not change to the first item when I click 'Update If' button. Please help, I am desperate.

  • Verified answer
    azizqureshi1 Profile Picture
    20 on at

    I have come up with a solution.

     

    On the Select property of the button 'Create Collection' create a copy of the collection col_Test, by ClearCollect(colNewCollecion,col_Test) at the end of the code.

     

    On the Select property of the button 'Update If' create a copy of the collection col_Test, by ClearCollect(colNewCollecion,col_Test) at the end of the code.

     

    The Items property of the gallery will be colNewCollecion.

     

    Now when the col_Test is updated a copy is made in the colNewCollecion. Since the Items property of the gallery is colNewCollecion. The changes are shown in the gallery. With out the items changing in the gallery.

     

     

  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @azizqureshi1 - as salaam mu alikom. Sorry I did not receive the usual notification that you had responded.

     

    Thanks for the description, it is a lot clearer.

     

    Why not set the Default property your Gallery to:

     

    LookUp(
     col_Test,
     Index = 2
    )

     

     

    Or:

     

    Index(
     col_Test,
     2
    )

     

  • azizqureshi1 Profile Picture
    20 on at

    Wa Alakum Salam my brother in Islam. Sorry for the late reply. My email is qxaziz123@gmail.com. Please send me message on my email. I would like to ask you some thing about power automate. 

     

    Jaza Kallah.

  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @azizqureshi1 - please raise your question in the Power Automate Forum and feel free to @ me there.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 762

#2
11manish Profile Picture

11manish 640

#3
Valantis Profile Picture

Valantis 548

Last 30 days Overall leaderboard