SharePoint UserData 和返回数据中的 ;# 语法
-
20-09-2019 - |
题
SharePoint 专家可以向我解释对列表 Web 服务的 GetListItems() 调用返回的数据中的 ;# 吗?
我想我明白他们在这里做什么。;# 几乎就像发表评论的语法......或者更好的是,包括实际数据(字符串)而不仅仅是 ID。这样您就可以使用其中任何一个,但它们在同一列中很好地配对在一起。
我离基地太远了吗?我只是无法弄清楚略有不同的用途。例如
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?*
任何人都可以阐明 SharePoint 的这方面吗?
解决方案
字符串 ;#
用作 SharePoint 查找字段(包括用户字段)的分隔符。使用对象模型时,您可以使用 SPFieldLookupValue
和 SPFieldUserValue
将分隔字符串转换为强类型对象。但是,在使用 Web 服务时,我相信您需要自己解析该字符串。
您是正确的,第一部分是整数 ID:站点用户列表中的ID,或查找列表中相应项目的ID。第二部分是查找列的用户名或值。
尼古拉斯正确地注意到该分隔符也用于其他复合字段值,包括......
- SPFieldLookupValueCollection
- SPField多列值
- SP字段多选值
- SPFieldUserValueCollection
其他提示
#符号;
在SPFieldUser从它使用的SPFieldLookup继承。你可以很容易地通过创建SPFieldLookupValue类的新实例解析值:
string rawValue = "1;#value";
SPFieldLookupValue lookupValue = new SPFieldLookupValue(rawValue);
string value = lookupValue.LookupValue; // returns value
不隶属于 StackOverflow