SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In querying the properties of a list item, I found that returning the value of a people or group field that the value would be returned in the form

1;#George Grainger

Using the code:

properties.ListItem["Staff Member"].ToString();

I've worked around the issue, by splitting into 2 strings, but I was wondering if anyone would know of a way to return the value without the ;# preceding the desired return value?

Note: I realise I could dig through the current web, list and item to query the fieldValue.User.Name, however this is somewhat resource expensive, and I was hoping for a "cleaner" way.

share|improve this question
up vote 6 down vote accepted

Use below code to get User name:

new SPFieldLookupValue(properties.ListItem["Staff Member"].ToString()).LookupValue;

For User ID:

new SPFieldLookupValue(properties.ListItem["Staff Member"].ToString()).LookupId;
share|improve this answer
Thank you, this was exactly what I was after! – George Grainger Feb 12 at 10:49

My understanding is that by using:

properties.ListItem["Staff Member"].ToString();

You are going to be returned their userID and username, so it will always be returned separated by ;#.

You're probably already using something like:

properties.ListItem["Staff Member"].ToString().split(";#")[1];

To return the username on it's own. You should compare the performance of that against fieldValue.User.Name and see which is less taxing.

There might be another field value I am missing that you could use in it's place, but I have always just split their ID from the name.

share|improve this answer
This was the workaround that I was alluding to in my question, I was hoping for the "proper" way to do it – George Grainger Feb 12 at 10:43

Your Answer


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.