Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

Gallery Default Item

Posted on by 73
Hi I am finding it impossible to set the default item in a gallery to a specific item ID. The data source is a sharepoint document library. I have tried for example:
 
Filter('Shared Documents',ID = 451))
 
But this does not work, any ideas how I do this?
 
Thanks
 
 
Categories:
  • WalesMariner Profile Picture
    WalesMariner 73 on at
    Gallery Default Item
    @ronaldwalcott This is what I am trying to accomplish:
     
    I have a form and a gallery on the same screen. The form is linked to a SharePoint List. The gallery is linked to a SharePoint Document Library. 
     
    The SharePoint List has lots of fields but the two relevant here are the 'Title' column and the 'DocID' column. Both of these appear as fields on the powerapp form.  
     
    When the form is in FormMode.New I am using the gallery to select from all the documents within Shared Documents, and with that selection, populate the forms Title field with the documents 'Name' and the forms DocID field with that document 'ID'.  When I hit the submit button this adds a new item to my SharePoint list (there are other unrelated bit of information that also go in other columns). This is working fine.
     
    When the form is in FormMode.Edit I need the Gallery to automatically select the document from all the documents within the Shared Document library that has the same ID (as was stored in DocID column of the SharePoint List) or the same Name (as stored in the title column of that list)
     
    In the example above I was just trying to filter to ID = 451 to see if I could actually return an item within the Gallery, really, I want to by able to dynamically match to the item being edited e.g. 

    Name = DataCardValue6.Text  or (DataCardValue6 being the Text entry field for that datacard)
    ID = Value(DataCardValue8.Text (DataCardValue8 being the Number entry field for that datacard)
     
    Hopefully that makes sense!
     
     
     
     
  • ronaldwalcott Profile Picture
    ronaldwalcott 1,026 on at
    Gallery Default Item
    Please provide more details on what you are trying to accomplish.
    Filter will select records but what do you want to do with those records?
  • WalesMariner Profile Picture
    WalesMariner 73 on at
    Gallery Default Item
    @SaiRT14 Do I set the context variable in the OnVisible property of the Screen, this is where I've tried it but its not working?
     
    Thanks
     
     
  • Suggested answer
    SaiRT14 Profile Picture
    SaiRT14 1,278 on at
    Gallery Default Item
    pls try the following:
     
    Filter for Specific ID: First(Filter('Shared Documents', ID = 451))
    Create a context variable for the default item: Set(DefaultItem, First(Filter('Shared Documents', ID = 451)));
    Bind the variable to the gallery’s Default or DefaultSelectedItems property: DefaultItem
     
    let me know if you need more details

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,487

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,014

Leaderboard