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 / Automatically select n...
Power Apps
Answered

Automatically select new item in gallery

(0) ShareShare
ReportReport
Posted on by 375

Hi,

 

I have set up a flow that creates a new file with data entered in an app. After the flow completes it prompts you to view the document on another screen. On said screen is a gallery with every document that has been generated. I would like it to automatically select the new document when you click the view document button.

 

I tried doing this by setting a variable called previewDocument with a record obtained using LookUp and finding the file in sharepoint. however, putting previewDocument in the default property of the gallery gives an error saying expected a value compatible with items. I tried using LookUp to look up all the items in the gallery and filter by the name of previewDocument. However, this causes some weird issues.

 

What is the best way around this?

 

Thanks

Categories:
I have the same question (0)
  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @BradonK ,

     

    Please try and return the new created file item ID from flow and save it into a variable at the run flow button. 

    Set(NewID, YourFlow.Run().ID);Navigate(FilesScreen)

     

    On the files screen, you can use LookUp in Default of the Gallery so when the Gallery comes out the very new created file is auto-selected:

    LookUp(Library, ID = NewID)

     

    Best regards,

  • BradonK Profile Picture
    375 on at

    @v-jefferni 

     

    Just tied what you suggested but it unfortunately gives the same error.

     

    Does what's in the "Items" box effect the "Default" behaviour?

    This is the code I have in "Items":

    Search(
     Filter(
     Filter(
     'MDR Generator Documents',
     Status.Value = "Open"
     ),
     EndsWith(
     'Full Path',
     ".docx"
     )
     ),
     DocumentFilterInput.Text,
     "{Name}"
    )

     

    If I put this in the default box instead I don't get an error, but it still doesn't work:

    LookUp(Filter(
     Filter(
     'MDR Generator Documents',
     Status.Value = "Open"
     ),
     EndsWith(
     'Full Path',
     ".docx"
     )
     ), ID = previewDocument.ID)

     

    Thanks

  • v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @BradonK ,

     

    Could you please share the error message with us? For your question, Items definitely affect Default, because the default item should be one of the Items. You may try below in Default:

    LookUp(Search(
     Filter(
     Filter(
     'MDR Generator Documents',
     Status.Value = "Open"
     ),
     EndsWith(
     'Full Path',
     ".docx"
     )
     ),
     DocumentFilterInput.Text,
     "{Name}"
    ), ID = previewDocument.ID)

     

    Best regards,

  • BradonK Profile Picture
    375 on at

    @v-jefferni 

     

    Unfortunately that still didn't work and the gallery defaulted to the first item in the list.

     

    Thanks

  • Verified answer
    v-jefferni Profile Picture
    Microsoft Employee on at

    Hi @BradonK ,

     

    Based on my test, if the default item is not one of the data table items, the Gallery will show the first item of the result table. So, you need to check if you have got the correct ID to your App. 

     

    Besides, the Default could be simplified to below:

    LookUp(
     'MDR Generator Documents',
     ID = previewDocument.ID
    )

     

    Please firstly find the ID in your App and check in Library to see if it's correct, secondly check if this doc is one of the items from result table of Search and Filter.

     

    Best regards,

  • BradonK Profile Picture
    375 on at

    @v-jefferni 

     

    Thanks for giving me the idea to check the IDs.

     

    They were not matching and that was the issue. I had swapped the location of my files to somewhere new and had changed most of the references to the old folder, but the ID that was getting stored when a file was generated was referencing the old folder not the new one, hence the mismatch. I deleted the old data source and tracked down the bad references and now it all works great.

     

    Thanks so much.

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 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard