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 / If Statement for Defau...
Power Apps
Answered

If Statement for Default Person Selection Returning Invalid Argument Type

(0) ShareShare
ReportReport
Posted on by 6

I have a tracker tied to a SharePoint List that assigns tasks to individuals in our office and utilizes an Office365Users connection to search for their account. I am able to search for them in a drop down ('Assigned to_DataCard2' and 'DataCardValue9') using 

 

Office365Users.SearchUser({searchTerm:DataCardValue9.SearchText,top:10})

 

as the Items property. My problem is that I would like the drop down to default to the current logged in user but am receiving an argument type error. I have tried 

 

If(EditForm1.Mode=FormMode.Edit,ThisItem.'Assigned to', Office365Users.SearchUser({searchTerm:User().Email}))

 

for the Default property of 'Assigned to_DataCard2' and

 

If(EditForm1.Mode=FormMode.Edit,Parent.Default, Office365Users.SearchUser({searchTerm:User().Email}))

 

for the DefaultSelectedItems of 'DataCardValue9' but both return an invalid argument type error saying they expected a record. What seems to strange to me is that if I replace the if statement which just one of the true or false statements (eg hisItem.'Assigned to' or Office365Users.SearchUser({searchTerm:User().Email})) it works without error. Thanks for any help you can give me.

Categories:
I have the same question (0)
  • Verified answer
    shoog Profile Picture
    2,164 on at

    The true and false parts of an If function should return the same datatype. Right now, the true part returns a record, where the false part returns a table.

    Since your SearchUser function will always return a single row table, you can simply select the first record.

    If(EditForm1.Mode=FormMode.Edit,ThisItem.'Assigned to', First(Office365Users.SearchUser({searchTerm:User().Email})))
  • Jcore80 Profile Picture
    6 on at

    That worked. Thank you.

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

#2
11manish Profile Picture

11manish 210

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard