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 Selected Item ...
Power Apps
Answered

Gallery Selected Item by default

(0) ShareShare
ReportReport
Posted on by 226 Moderator
It has been a while since I have posted, but this one has me stumped!
Background - I have a project system that tracks contracts associated with the selected project. Each contract is also associated with a type (ie. Labor, Material, Other, etc...).
The type (is a collection - colContractType) that gets built from a SharePoint List. And this I have no issue with. Collection gets built based on Filter() and I am using AddColumn() and ShowColumn() to reduce the number of columns in the collection.
What I am trying to do is this:
When you "Add" a new contract to the list from in colContractType, there is no item selected by default. I am using {} in the Default field of the Gallery that displays the collection. Alone this works perfectly.
But when I select a specific contact from the Gallery of Contracts, I set a variable (_contEdit) so the form is not blank, but it displays the current SharePoint list item for editing.
If I put
 

 

If(
 _contEdit,
 {},
 LookUp(Contracts, Gallery1.Selected.ID = ID, contractType)
)

 

As a default value for the Property of the Gallery, I get an error ' expected a value compatible with items'
I would like to have the "Add New" show nothing selected and when in Edit Mode have the SharePoint Source Data value from the list shown.
I hope that makes sense.
Categories:
I have the same question (0)
  • Verified answer
    gcmfaizan Profile Picture
    1,022 on at

    @Hack-7 you are doing right but you do it vise-versa do it like this:

    If(_contEdit, LookUp(Contracts, ID = Gallery1.Selected.ID, contractType), {})

     

    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

     

    Thanks!

     

  • Hack-7 Profile Picture
    226 Moderator on at

    @gcmfaizan Yes, that was one of the issues...  And I did see my mistake seconds after I posted this question.  

    But, I was making a mistake on my Lookup().  I had my other list set as the data source and not the built collection.

     

    Sometimes it helps to write the question out to find the answers!  Cheers

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

#2
11manish Profile Picture

11manish 193

#3
Valantis Profile Picture

Valantis 138

Last 30 days Overall leaderboard