I either want the e开发者_StackOverflow中文版mail address or the user account of the user who created or modified a list item.
I was thinking calculated field, but you can't do a calculated field on created by or modified by fields!
Is this possible?
"Want the email address" - just for display, or via code or something else?
Every list has two internal fields
- Author - who created
- Editor - who last modified (= Author if new record)
If its via code then running from a web part (so you have SPContext)
// Assuming SPListItem already setup in currentItem
// Get the author field as a user
SPFieldUserValue author = new SPFieldUserValue(
SPContext.Current.Web,
currentItem["Author"].ToString());
string emailAddress = author.User.Email;
The calculated column will not work in this case. You might have to use an event handler or workflow, but be careful to handle infinite looping as, whenever you will update the new column, a modfied event would be raised, and that can trigger the workflow or event handler.
精彩评论