Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a requirement that I have to get the list item values in SharePoint list item updating event. In that I am getting list item properties( current properties ) and also updated values( after properties ), except the people picker value.

as that

string cuurentUser= properties.ListItem["User"].ToString();
( Result: "22;#RAMPINDIA/ventew")
string afterUser= properties.AfterProperties["PermissionLevel"].ToString(); (Result:"22")

as shown above I am just getting the ID only.

Can any one help me to find the way to find the entire name?

share|improve this question
    
Based on your sample, it would seem that you aren't reading the before and after values from the same field... Is that right? –  SPArchaeologist Dec 15 '11 at 14:35
    
yes, in after properties iam reading all fields except the people picker value... –  suresh Dec 16 '11 at 3:49
    
Wow... 0% accept rate. –  Robert Kaucher Apr 18 '12 at 17:35

2 Answers 2

If you are accessing to lookup field in AfterProperties, you always get only lookup id. User field is also lookup to User Information List, so you must get user using GetById(int ID) as @Stuart Pegg suggests. But there are some pitfalls when you accessing to lookup fields in event receivers, I've posted about this pitfalls in my blog, check it out:

Accessing SharePoint lookup fields values in item receivers - some pitfalls
Working with SPFielduserValue in item event receivers - some pitfalls

share|improve this answer

I believe you should be able to use the SPWeb.AllUsers.GetById(int ID) method to get the SPUser for that ID, and then use that object's properties to get the required information:

MSDN: SPUserCollection.GetByID Method

MSDN: SPUser Members

Also, you can use SPFieldUserValue(SPWeb, string) constructor to get an SPFieldUserValue object from your current properties string, and use SPFieldUserValue.User to get an SPUser object. More details on using SPFieldUserValue can be found on my blog:

TssTssT: Easily accessing Lookup and User fields

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.