SharePoint UserData and Syntax # in the returned data

Can a SharePoint specialist explain to me; # in the data returned by the GetListItems () call to the lists web service?

I think I understand what they are doing here. The; # almost like syntax for making a comment ... or better yet, including the actual data (string), not just the ID. So you can use them, but they fit nicely together in one column.

Am I so far away? I just can't figure out how little use it is. for example

I have a list with:    
ows_Author  
658; #Tyndall, Bruno    
* in this case the 658 seems to be an ID for me in a users table somewhere *

ows_CreatedDate (note: a custom field. not ows_Created)    
571; # 2009-08-31 23:41:58    
* in this case the 571 seems to be an ID of the row I'm already in. Why the repetition? *   

Can anyone shed some light on this aspect of SharePoint?

+2


source to share


2 answers


The string is ;#

used as a delimiter for SharePoint search fields, including user fields. When you work with the object model, you can use SPFieldLookupValue

and SPFieldUserValue

to convert a string delimited in a strongly typed object. However, when working with web services, I believe you will have to parse the string yourself.

You are correct that the first part is an integer ID: an ID in the list of site users, or the ID of a corresponding item in a search list. The second part is the username or the value of the search column.




Nicolas correctly notes that this separator is also used for other composite field values, including ...

  • SPFieldLookupValueCollection
  • SPFieldMultiColumnValue
  • SPFieldMultiChoiceValue
  • SPFieldUserValueCollection
+8


source


SPFieldUser inherits from SPFieldLookup, which uses the # notation. You can easily parse the value by creating a new instance of the SPFieldLookupValue class:



string rawValue = "1;#value";
SPFieldLookupValue lookupValue = new SPFieldLookupValue(rawValue);
string value = lookupValue.LookupValue; // returns value

      

+3


source







All Articles