Adding spfielduservalues to a list keeps failing
-
Got a list that will hold domain accounts so I can have access to their email addresses. I am using the following code to add them to the list:
Dim exec As New SPFieldUserValue
For Each entity As PickerEntity In sppeExecs.ResolvedEntities
web.EnsureUser(entity.Key)
exec = New SPFieldUserValue(web, Convert.ToInt32(entity.EntityData("SPUserID")), entity.Key)
Next
'now, get the list and create the item container
Dim execList As SPList = web.Lists.TryGetList(ListName)
If execList Is Nothing Then
errorMessage.InnerText = "Sorry, but the Executive Director List could not be loaded. Please contact the IT Department Help Desk @ extension 2195."
Exit Sub
End If
Dim execItem As SPListItem = execList.AddItem()'add the executive user object and set the active field to true execItem(Name) = exec execItem(Active) = True
What happens is in the For Each loop at the beginning the exec variable isn't being loaded with a value. I've done this before and it has always worked, so I don't know what I must have forgotten to do.