I have a custom list for example "MyCustomListA" I have created a custom ListForm template and overide the ListFieldIterator. I have overide the ListFieldIterator and CreateChildControls to implement some readonly logica depandant of user membership.

One of the fields is a lookup to another custom list (MyCustomListB). In this custom list I am using a custom content type with 2 fields:


1: Title

2: Person or Group

The lookup shows a dropdownlist with for each item in "MyCustomListB" only the title. I would like to get the "Person or Group" value, someone know how??

public class CustomListFieldIterator : ListFieldIterator

    protected override void CreateChildControls()
    // some logic to set readonly depandant by user membership    

    protected override bool IsFieldExcluded(SPField field)
                  // some logic
                        // get users and groups from this field
                        SPUser selectedUsers = field.Some logic...
                        SPGroup selectedUserGroups = field.Some logic...
                        // some logic


  • in which moment do you want to get this value, after user pressed "Save" in new\edit form? – Sergei Sergeev Feb 10 '13 at 20:41

This should do it for you:

SPFieldUser userField = (SPFieldUser)item.Fields.GetField("UsersAndGroups");
SPFieldUserValue userFieldValue = (SPFieldUserValue)userField.GetFieldValue(item["UsersAndGroups"].ToString());
SPUser user = userFieldValue.User;

If you want more examples (e.g. when using multi-value selections) see here http://dsen-25.blogspot.ch/2012/07/how-to-get-spuser-or-spgroup-from.html

[EDIT after Comments]: If the UserAndGroups column is actually pointing to another list having one column of type "Person or Group" you need to use something like expressed here Get related items from a parent list item through lookup

  • Thanks for your support.. what do I need to fill in as currentValue?? Is it the column name from MyCustomListB? – Ola Feb 10 '13 at 16:19
  • updated code with a piece from the article adapted to your case – Marius Constantinescu - MVP Feb 10 '13 at 17:27
  • I dont have an item object in my code. How can I get current item in the IsFieldExcluded method? – Ola Feb 10 '13 at 18:06
  • but you do, using this.Item as you are using the ListFieldIterator class msdn.microsoft.com/en-us/library/… – Marius Constantinescu - MVP Feb 10 '13 at 18:15
  • are we talking about SPItem or SPListItem? – Ola Feb 10 '13 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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