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 / Form not loading corre...
Power Apps
Unanswered

Form not loading correct selecteditem from Gallery

(0) ShareShare
ReportReport
Posted on by 18

Form not loading correct selecteditem from Gallery


This one has me stumped... Here's my set up:

Page with a Gallery
Item gets selected
Navigate to another page with a form
the form item actually filters a second Sharepoint List to look up another item which is realted to the item selected in the gallery
Here's the issue... the first time I select an item from the gallery, no matter which item is selected, the form shows the first item in the gallery. If I go back to the gallery page again, and try selecting the other item again, then the form will load the appropriate item. Ex:

 

Gallery:

Item 1
Item 2
Item 3
Item 4
User selects Item 4

OnSelect = Select(Parent); Navigate('Feedback Screen',ScreenTransition.None)


Feedback form shows, but the data in the form matches Item 1 not Item 4. This only happens the first time through, if you go back to the gallery, and select Item 4 again, the feedback form will show Item 4 data. This happens no matter which item is selected and only the first time through. The Form item property is set to:

 

Item = First(Filter('second Data Source',parentID = 'Gallery 1'.Selected.ID))

I've tried storing the Selected.ID in a variable (using Select(Parent); Navigate('Feedback Form',ScreenTransition.None,{mySelectedItem:ThisItem.ID})) and having the Form.Item property read from the mySelectedItem variable instead of the gallery directly. To get visibility to what was going on, I set a label on the feedback screen to show the contents of 'Gallery 1'.Selected.ID and my variable. It show the varible was set correctly, but the 'Gallery 1'.Selected.ID still points to the first item (even though it wasn't selected).


I've tried using RefreshFrom both before and after the navigate step. I refresh all data source onStart of App to ensure nothing is cahced.

 

I'm running out of ideas on how I can force it to use the truly selected item and not the first item for the first time through.

Categories:
I have the same question (0)
  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at

     

    Try using lookup instead of Filter on the item. 

     

    Item = Lookup('second data source',parentID = Gallery1.Selected.ID).ID

  • KroonOfficeSol Profile Picture
    587 on at

    @toysibuy

     

    This is strange, but good come from the fact that the selected items is not instantly set where thisitem.id is. Probably when you wait some time the gallery will update. So basically you have a bad performance issue I think.

     

    What you could do is to delete the navigation part for now and add a label (on .Text do the gallery1.selected.ID), see what the label does when clicking item 4. How long does it takes to update?

     

    Just to see what happens, because you should use the variable in the form.item like

    First(Filter('second Data Source',parentID = MySelectedItem))

    This makes you can use the screen from differt screen off your app if you want to and you can clear the MySelectedItem and do Reset(Form) before leaving the second screen. Then there wont be echo's in your form from an earlier selection.

     

    Hope this helps,

     

    Paul

     

  • Verified answer
    toysibuy Profile Picture
    18 on at

    Thanks everyone for the suggestions!

     

    So I did manage to get this to work... it turns out the approach of setting it in a variable did work after all.  The form was pulling the correct data using this method.  I also had some header information above the form, that I forgot to update... so it wasn't using the variable and was still set to gallery.selected.id, this made it appear to be wrong.  Once I set those label to also reference the variable and not the gallery directly, everything is now in sync.

    So this was a nice workaround, but it just make me nervous that referencing the gallery directly did not seem to work.  I have several othe powerapps and they all reference the galleries.  I wonder if they are working or if just none of my users have noticed the issue.

  • Sarang24Dev Profile Picture
    29 on at
    The approach of using a variable doesn't work for me. It still shows the wrong item in the form.
  • Ubertortle Profile Picture
    52 on at

    It appears this is still an issue. It was doing this to me before and I had thought I fixed it by refreshing data source before navigation but the issue has returned.

  • Gyllentid Profile Picture
    894 on at

    Any news on this? Anyone of you found a way to do it easier?

  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at

    Remove onselect from the gallery and on the actual gallery item(template) onselect add in set(varSelecteditem,ThisItem.selected.ID) I’ve always used this method and never had an issue.  

  • Gyllentid Profile Picture
    894 on at

    @cwebb365 May I ask... Do I have to put varSelectedItem as it is or do I have to declare it somewhere? And does ID refer to a universal entity or should I change that?

  • cwebb365 Profile Picture
    3,294 Most Valuable Professional on at

    No, just using Set() anyway creates a global variable if one doesn't exist. using .ID is just using that value, saving space, you would do ThisItem.Selected and reference all column if you want too, but I just do whatever column you need in the lookup for the Items property in the form. usually ID, so for that lookup(datasource,id = varSelectedItem) or varSelectedItem.ID if you use just selecteditem. 

  • Gyllentid Profile Picture
    894 on at

    @cwebb365 So, I add 

    set(varSelecteditem,ThisItem.selected.ID)

    To the gallery Item in their OnSelect. I think I am misunderstanding something... I get errors for the name being unrecognized and invocation of unknown function. When you say ID, do you mean the id for the entity or the column display name?

    Skärmavbild 2021-12-01 kl. 09.43.57.png

    I deleted the OnSelect on the gallery also 👍

     

     

     

     

     

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