sharepoint 2013 user field value types?

867 Views Asked by At

i would like to read a user field value from properties.AfterProperties(or the list item) in an ItemUpdating event receiver and get a SPUser (or at least a SPFieldUserValue) object so i tried:

var fldValue = properties.AfterProperties[fldName] ?? properties.ListItem[fldName];
result = (SPFieldUserValue)fldValue;

an exception informed me that i cannot cast from string to SPFieldUserValue. debugging confirmed that the field value type is string.

in this case the user field is declared as Type="User" in the list schema, other user fields in the same list are declared as Type="UserMulti" and for those the field value is of type SPFieldUserValueCollection...

now i'd like to know if this is the way sharepoint handles user fields in general or if this is just a bug in a badly configured vm? because handling single and multi user fields differently isn't that bad, i just need to know if i can rely on those types for field values: single user field -> string and multi user field -> SPFieldUserValueCollection?

0

There are 0 best solutions below