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 / preselect lookup field...
Power Apps
Answered

preselect lookup field's value

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello Community!

 

I'm trying to build an event inscription management app.

It all starts in CDS with 3 different entities: Events, Inscriptions and Users.
Event contains data for the event, location, date, name of event, etc.
Inscription contains data such as the inscription number, days of presence, manager approval, etc.
User contains a bit more personal data such as the user's name, email, allergies, restriction, location and other personal info.
Those entities are related this way: Event -(one to many)- Inscriptions -(many to one)- Users

Thus, I have 2 lookup fields in Inscriptions, one that picks an event and another that picks a user's name (In my case called Participant).

When creating or modifying an user profile via a form (Users entity), the name and email address fields are pumped from the AD via the User().Fullname and User().Email functions under Default in a text field and the display mode is set on Displaymode.view. No problem here!

Now, When comes the time to re-do the same with the user's name (lookup field now), under Default I replace ThisItem.Participant (contains the user's name in my case) with User().Fullname , I get an error (see image). So how do I solve this problem without messing my entities' relationships? Is there a workaround?
The whole purpose of this is to make sure that an user cant only submit an inscription for himself and no other user.

Many thanks!

2020-02-21 10_18_01-.png
2020-02-21 10_22_37-.png
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,454 Most Valuable Professional on at

    Hi @Anonymous ,

    I will start with what I believe may be a simple solution and go from there if this is not the case. 

    The error appears to be a Delegation warning on User().Email  (User().FullName would receive one too as neither are delegable filters).

    The easy workaround is to set Global Variables on App OnStart and use these in your filter

    Set(vUserName,User().FullName);
    Set(vUserMail,User().Email)

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @WarrenBelz for your quick response!

     

    Unfortunately this workaround did not solve my issue as I get a unexpected text or number error.

     

     

    test.png
  • WarrenBelz Profile Picture
    156,454 Most Valuable Professional on at

    Thanks @Anonymous ,

    That eliminates one of the bigger delegation issues, but does not solve your issue and it is strange that a variable of the same value produces a different error.

    However I am not a CDS expert, so I will tag one of my colleagues @Anonymous for an opinion.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz thanks for the tag, I'll see if I can help but I've not worked with CDS before so maybe ... maybe not? I will also tag @PowerAddict here as well just to check my input. He has good working knowledge of CDS.

     

    @Anonymous 

    It would appear you are trying to replace a record (ThisItem.Participant) with a value (User().FullName) which is causing the error. My idea would be to trying using this record call instead:

     

    LookUp(Users, Participant.FullName = User().FullName, FullName)

     

    You could also use @WarrenBelz suggestion for variables if the above throws errors - always good to throw the User().FullName and User().Email into variables because they can cause a number of issues.

     

    Now, I'm not across all of the attribute (column) names in the CDS entities but where I have 'FullName' above in reference to the 'Users' entity it maybe called something else, not sure?

     

    Let me know how you get on, and maybe @PowerAddict can confirm/correct the above as required 🙂 

  • Verified answer
    PowerAddict Profile Picture
    7,316 Most Valuable Professional on at
    Thank you @Anonymous and @WarrenBelz for the tag.

    @Anonymous, the explanation of the issue given by @Anonymous is correct.

    It expects a record of type User and User().FullName just gives you text. Also, it is very easy to get confused with the Users entity and the User() function. User() function is just to retrieve values like name, email and image of the current logged in user. Whereas the Users entity is the complete list of user records.

    You can however use the User() function to do a lookup on the Users entity.

    LookUp(Users, 'Full Name' = User().FullName)

    You should be able to use this as your Default property of the dropdown of users. One suggestion, use email as the lookup value, rather than fullname as technically there is a possibility of 2 people having the same full name especially since FullName only gives you FirstName + LastName.

    Also, if you dont want the user to be able to select a diff user, you may want the User dropdown to be disabled or view only. Set the datacard's DisplayMode property as:
    DisplayMode.View or DisplayMode.Disabled.

    My lookup expression may not be exactly right as I am not in front of my computer but am fairly certain it should work.

    Let me know if it doesn't and I should be able to test it out in a few minutes.

    Hope this helps.

    ---
    If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

    Thanks!
    Hardit Bhatia
    The Power Addict
    https://thepoweraddict.com
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @WarrenBelz , @Anonymous  and @PowerAddict!

    It worked by setting my the Default to Lookup(Users, 'Full Name' = vUserMail)
    Where vUserMail is the variable proposed by @WarrenBelz on my appstart which stores the user's name.

     

    Thank you all for your support!

  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at
    Glad I could help! Good luck with the rest of your app! Feel free to reach out in case of any questions!

    Thanks,
    Hardit Bhatia
    The Power Addict
    https://thepoweraddict.com

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