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 goes to the wr...
Power Apps
Unanswered

Gallery goes to the wrong item at first

(0) ShareShare
ReportReport
Posted on by 130

When the app is loaded or refresh for the first time, I click on any item to view details and the first item in the gallery shows instead of the one i click on. After that gallery works excellent. This is a first try error. Please help. I can't find a solotion. Any idea.

 

Thanks,

Learn

Categories:
I have the same question (0)
  • tly Profile Picture
    400 on at

    I see your initial post (Details screen not display the right selected item). This post seems to have more details, so let's work off of this.

    So when you say you click on a gallery, there is an icon or object that you are clicking on. For example, let's say it's an arrow icon called iconArrow. It's property might look something like this:

    iconArrow.OnSelect =
     Navigate(screen2, ScreenTransition.Fade)

    If iconArrow.OnSelect has more syntax involved, you may want to consider this syntax to see if there's any discrepancy.

    And then on screen2, there might be a form (e.g. form2) on screen2 that displays the details. The important thing to look at here is form2.DataSource and form2.Item. If your details are not on a form, it may be on a textbox or label (e.g. textbox1) or something of the life. If so, you may want to look at textbox1.text

     

  • tly Profile Picture
    400 on at

    If you can include the syntax in these property/events, it may be more helpful to answering your inquiry.

  • LEARN_IT Profile Picture
    130 on at

    I don't have any form on the details screen. They are labels=Gallery3.sellected.Items(ID,date,location, etc...)

  • tly Profile Picture
    400 on at

    This is a very unique incident. In instances like this, the devil is in the details. Can you provide screenshots of your Advanced Settings for your main gallery and your details textbox(es)?

  • LEARN_IT Profile Picture
    130 on at

    I traced down and the problem is in Gallery properties. I created a new gallery with no filter and it works, put my all my filter back and it didnt work.

  • tly Profile Picture
    400 on at

    What is your gallery.Item's filter syntax?

  • LEARN_IT Profile Picture
    130 on at

    Items:

    If(IsBlank(TextSearchBox1_8.Text),
    Sort(
    If(type="New",Filter(Tickets,Status="New"),If(type="MyNew",Filter(Tickets,Status="New" && TechEmail=currentUser_1.Text),
    If(type="MyInprogress",Filter(Tickets,(TechEmail=currentUser_1.Text && Completed="No" && Status="In progress") || (TechEmail=currentUser_1.Text && Status="Awaiting Info") || (TechEmail=currentUser_1.Text && Status="Info Received")),
    If(type="Cancelled",Filter(Tickets,Status="Cancelled" ),
    If(type="Received",Filter(Tickets,Status="Info Received" && Completed="No" && TechEmail=currentUser_1.Text),
    If(type="All",Filter(Tickets,Completed="No" ),
    If(type="MyAll",Filter(Tickets,Completed="No" && TechEmail=currentUser_1.Text),
    If(type="In progress",Filter(Tickets,(Status="In progress" && Completed="No") || (Status="Info Received" && Completed="No") || (Status="Awaiting Info" && Completed="No")),
    If(type="On hold",Filter(Tickets,Status="On hold" && Completed="No"),
    If(type="MyOnhold",Filter(Tickets,Status="On hold" && Completed="No" && TechEmail=currentUser_1.Text),
    If(type="Closed",Filter(Tickets,Status="Closed"),
    If(type="LEARN HH",Filter(Tickets,Location="LEARN HH" && Completed="No"),
    If(type="SSS",Filter(Tickets,Location="SSS" && Completed="No"),
    If(type="TRMC",Filter(Tickets,Location="TRMC" && Completed="No"),
    If(type="DLAMMS",Filter(Tickets,Location="DLAMMS" && Completed="No"),
    If(type="CTRA",Filter(Tickets,Location="CTRA" && Completed="No"),
    If(type="TFS",Filter(Tickets,Location="TFS" && Completed="No"),
    If(type="MSMHS",Filter(Tickets,Location="MSMHS" && Completed="No"),
    If(type="RMMS",Filter(Tickets,Location="RMMS" && Completed="No"),
    If(type="AllLocation",Filter(Tickets,Location="ALL Location" && Completed="No"),
    If(type="3daysOld", Filter(Tickets, Completed="No",DateCreated <> datetype && DateCreated <>Text(Today()), DateCreated <> Text(DateAdd(Today(), -2)),DateCreated <> Text(DateAdd(Today(), -1)))))))))))))))))))))))),

    Modified,Descending),
    SortByColumns(
    Search(Tickets, TextSearchBox1_8.Text, "Comment","Status","AssignedTo","RequestID","ServiceTypes","Location","Title","Subject","Description")
    ,"Modified",Descending))

     

    OnSelect: Navigate(TicketdetailsPage,ScreenTransition.None,{PsFeatures:false,TSelected:ThisItem.ID,TAssetID:ThisItem.AssetID})

  • tly Profile Picture
    400 on at

    At first glance, it looks like your filter is quite long, which could possibly contribute to PowerApps's confusion when navigating.

     

    If(IsBlank(TextSearchBox1_8.Text),
     Sort(
     If(type="New",
    Filter(Tickets, Status="New"),
    If(type="MyNew",
    Filter(Tickets, Status="New" && TechEmail=currentUser_1.Text), If(type="MyInprogress",
    Filter(Tickets,
    (TechEmail=currentUser_1.Text && Completed="No" && Status="In progress") ||
    (TechEmail=currentUser_1.Text && Status="Awaiting Info") ||
    (TechEmail=currentUser_1.Text && Status="Info Received")), If(type="Cancelled",
    Filter(Tickets, Status="Cancelled"), If(type="Received",
    Filter(Tickets,Status="Info Received" && Completed="No" && TechEmail=currentUser_1.Text), If(type="All",
    Filter(Tickets,Completed="No" ), If(type="MyAll",
    Filter(Tickets,Completed="No" && TechEmail=currentUser_1.Text), If(type="In progress",
    Filter(Tickets,
    (Status="In progress" && Completed="No") ||
    (Status="Info Received" && Completed="No") ||
    (Status="Awaiting Info" && Completed="No")), If(type="On hold",
    Filter(Tickets,Status="On hold" && Completed="No"), If(type="MyOnhold",
    Filter(Tickets,Status="On hold" && Completed="No" && TechEmail=currentUser_1.Text), If(type="Closed",
    Filter(Tickets,Status="Closed"), If(type="LEARN HH",
    Filter(Tickets,Location="LEARN HH" && Completed="No"), If(type="SSS",
    Filter(Tickets,Location="SSS" && Completed="No"), If(type="TRMC",
    Filter(Tickets,Location="TRMC" && Completed="No"), If(type="DLAMMS",
    Filter(Tickets,Location="DLAMMS" && Completed="No"), If(type="CTRA",
    Filter(Tickets,Location="CTRA" && Completed="No"), If(type="TFS",
    Filter(Tickets,Location="TFS" && Completed="No"), If(type="MSMHS",
    Filter(Tickets,Location="MSMHS" && Completed="No"), If(type="RMMS",
    Filter(Tickets,Location="RMMS" && Completed="No"), If(type="AllLocation",
    Filter(Tickets,Location="ALL Location" && Completed="No"), If(type="3daysOld",
    Filter(Tickets,
    Completed="No",
    DateCreated <> datetype && DateCreated <>Text(Today()),
    DateCreated <> Text(DateAdd(Today(), -2)),
    DateCreated <> Text(DateAdd(Today(), -1)
    ))))))))))))))))))))))), Modified,Descending)
    , SortByColumns( Search(Tickets, TextSearchBox1_8.Text, "Comment","Status","AssignedTo","RequestID","ServiceTypes","Location","Title","Subject","Description"),
    "Modified",Descending)
    )

    I'm guessing you have a textbox or a dropdown that the user can change, thus, assigning the value of type, and defining the type of filter to use on your gallery.

    If it were up to me (and it is not), I would create separate dropdowns for the filtered columns (e.g. Location, Completed, DateCreated, etc.) and then they could be individually used to filter the gallery; however, I understand that people cater their design to the form and shape that makes the most sense to them. So, if you want to do a templated view type, here is one way to approach this:

    1. Make a note of the columns in your dataSource (Tickets) that you are filtering. These just happen to be in no particular order: 
      1. Status
      2. TechEmail
      3. Location
      4. Completed
      5. DateStart
      6. DateEnd
    2. Since you are using your predefined templates (e.g. "New", "MyNew", etc.), then we need to make a note of that as well.
    3. Create a collection based on this information in the Screen.OnVisible:
      ClearcCollect(myFilters,
       Table(
       {
       TemplateName: "New",
       FilterStatus: "New",
       FilterTechEmail: Blank(),
       FilterDateStart: Blank(),
       FilterDateEnd: Blank(),
       FilterCompleted: "No",
       FilterLocation: Blank(),
       ListOrder: 1
       },
       {
       TemplateName: "MyNew",
       FilterStatus: "New",
       FilterTechEmail: currentUser_1.Text,
       FilterDateStart: Blank(),
       FilterDateEnd: Blank(),
       FilterCompleted: "No",
       FilterLocation: Blank(),
       ListOrder: 2
       },
       etc...
       {
       TemplateName: "3daysOld",
       FilterStatus: Blank(),
       FilterTechEmail: Blank(),
       FilterDateStart: Today() - 3,
       FilterDateEnd: Blank(),
       FilterCompleted: No,
       FilterLocation: Blank(),
       ListOrder: 20
       }
       )
      )
    4. The net result is that you will have a collection--in in-memory table--with the values that you will eventually filter your gallery with.
    5. Create a dropDown control. We leverage the ListOrder field in the new collection to put these items in the order you desire. Let's call this DropDown1. Set it's items accordingly (making sure to set its DisplayFields in the Advanced settings to ["TemplateName"]):
      DropDown1.Items =
       SortByColumn(myFilters,
       ListOrder, Ascending
       )
    6. Now you have a dropdown that shows your template filters. It's time to give your gallery filter a facelift:
      Search(TextSearchBox1_8.Text,
       Filter(Tickets,
      
       If(IsBlank(DropDown1.Selected.Status),
       true,
       Status = DropDown1.Selected.FilterStatus
       ),
      
       If(IsBlank(DropDown1.Selected.FilterTechEmail),
       true,
       TechEmail = DropDown1.Selected.FilterTechEmail
       ),
      
       etc. with the other filters...
      
       ),
       "Comment", "Status", "AssignedTo", "RequestID", "ServiceTypes", "Location", "Title", "Subject", Description"
      )
    7. This will trim your If-Statements down from 21 statements down to 6. Plus, if you ever create new templates in the future, you just update your collection table (step 3) and you will remain at  6 If-Statements. In fact, you no longer have to touch your gallery filters (unless you want to add new columns to filter).

     

    As far as your navigation:

    Object.OnSelect = 
     Navigate(TicketdetailsPage,
     ScreenTransition.None, 
     {PsFeatures:false,TSelected:ThisItem.ID,TAssetID:ThisItem.AssetID}
     )

    There's nothing wrong with using variables (e.g. PsFeatures, TSelected, TAssetID, etc.). In PowerApps, variables are finnicky. That's because PowerApps doesn't always do everything in chronological order. It's sort of like telling a bunch of 5th graders how to clean up the classroom and telling them to execute. The guys who are supposed to clean up on step2 might goof up and take longer than intended; the guys in step3 might finish before. When you take a snapshot, especially with a bunch of if-statements and data loading here-and-there, the result is finnicky at best. You're better off referring to an absolute value.

    The values and properties of your gallery (let's call it Gallery1) are absolute. The good news is that they're also universal, meaning you can refer to its values and properties from any screen. Let's say your tickets have a column called Details. And TicketdetailsPage has a textbox called textDetails and another called textAssetID. You would just have to do this:

    textDetails.text =
     gallery1.Selected.Details

    textAssetID.text =
    gallery1.Selected.AssetID

     

    Even if this doesn't solve your problems, I hope it gives you a different perspective of simplifying and troubleshooting the solution.

     

  • LEARN_IT Profile Picture
    130 on at

    I really appreciate your time on this. i will look at your ideas once i get back from vacation. If you don't hear anything from me: reason im away from work. happy holiday.

     

    Thanks

    LEARN

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard