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 / PATCH statement not wr...
Power Apps
Unanswered

PATCH statement not writing User().Email to a single line of text field in sharepoint list

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a SP list that I am writing to using a Patch statement in powerapps 
I have a Name column of type: single line of text.

I am attempting to write the email address of the current user to the name column using User().Email in my patch statement.  I am also writing the current time to a time column with Now(). (There are obviously other columns i am writing to but I even tried creating a button to just write the name and time to see if i could get that to work, it would not)

When i click on the button running the patch statement a new record is created and the time is entered in the time column, but the user email is NOT in that column, it is blank.  
Patch(SPLISTNAME,Defaults(SPLISTNAME),{Time:Now(),Name:User().Email})

My column settings are 255 characters and not unique.  I can go into the sharepoint list directly and manually enter a record, typing in an email in that column and it does save it.

Interestingly, I'm only having this trouble in my personal sandbox app; our dev app has this same "User().Email" code in a patch statement and I am NOT having issues with, it DOES write the user email to the name column in its sharepoint list.  I have compared the code in the patch statement and do not see any differences.  the name column in each respective SP list is a single line of text type.  

What would be causing an identical patch statement to write all other columns except the name column using User().Email.  I have not even been able to write a literal value to the name column with the patch statement. I've even tried setting a label's text to User().Email just to confirm the email is being retrieved (it is), and then writing the text value of that label to the name column in my patch statement and that doesnt work either.

Ironically, writing to the name column used to work in my app, but at some point it stopped working.  I have refreshed my data source, i have even removed and readded my datasource to my app.  I have not made any changes to the name column on my SPList.  I have looked at this on multiple days to hopefully catch something that my tired eyes didnt see before but to no avail. 

 

I guess in my sandbox version (where im trying out various functionality before adding it to our dev app) this is not critical since the name column does work in my dev app, but it's been nagging at me as to why it won't work.

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Also, I dont know if this is related but I am getting the following error when i open my app.  The part in my patch statement where i use the Office365Users.UserProfile is correctly writing to the SP list, so i dont know why i would be getting that error when i just opening the app, when i click the patch button it writes to the following column correctly.  Im writing to the "company" field using the .CompanyName attribute of UserProfile.
    Part of my patch statement - Company:Office365Users.UserProfile(varEmailAddress).CompanyName

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

    Hi @ToddS ,

    Firstly, assuming varEmailAddress contains a valid email address in your AD and you have the Office365Users connector included in your data sources, then this

    Office365Users.UserProfile(varEmailAddress).CompanyName

    is valid and should Patch the user's company name to the Company field. What is your OnStart code that refers to userid (where you are getting your error)

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