删除“#” 来自 SharePoint ListItem 数据

发布于 2024-07-23 07:41:55 字数 193 浏览 12 评论 0原文

在 SharePoint 中,许多字段 id-value 对的格式类似于以下 id;#value。 对于诸如多重查找之类的字段来说,情况变得更加复杂,其中提取该字段的值时可以产生诸如 id_1;#value_1;#id_2;#value_2;#id_3;#value_3 这样的结果

我想知道是否有任何已知的内置函数将简化此过程并至少从值中删除 ID。

In SharePoint many fields id-value pairs that are formatting like the following id;#value. This is further complicated with fields like multi-lookup where when extracting the value of that field can yield results like id_1;#value_1;#id_2;#value_2;#id_3;#value_3

I am wondering if there is any known built in function that will simplify this process and at the very least remove the IDs from the value.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╰◇生如夏花灿烂 2024-07-30 07:41:55

字段值对象作为字符串存储在 Sharepoint 数据库中。 对于简单的值(例如“Hello world”),这很简单。 但对于复杂的字段值(例如 ID/值对),如何将整个值存储为单个字符串显然也更加复杂。 Sharepoint 中的每个字段值类负责其自己的存储实现。 ToString() 负责写入值的字符串表示形式; 而字段值的构造函数接受一个字符串,并负责解析该字符串并适当地设置其自身的所有属性。

例如,SPFieldUrlValue(表示 description)具有 Url 和 Description 属性。 创建新的 SPFieldUrlValue(string fieldValue) 对象将解析该值并相应地设置属性。

为了获得字段值的真实/正确(通常是强类型!)表示,您必须知道该字段是什么类型,以及该字段的值类是什么。

Field value objects are stored as strings in the Sharepoint database. For simple values (e.g. "Hello world") this is simple enough. But for complex field values - such as an ID/value pair, how to store the entire value as a single string is obviously more complex as well. Each field value class in Sharepoint is responsible for its own storage implementation. ToString() is responsible for writing a string representation of the value; while the field value's constructor takes a string and is responsible for parsing that and setting all the properties on itself appropriately.

For example, the SPFieldUrlValue (which represents an <a href="url">description</a>) has Url and Description properties. Creating a new SPFieldUrlValue(string fieldValue) object will parse the value and set the properties accordingly.

In order to get a true/correct (and often strongly-typed!) representation of the field value, you must know what type the field is, and what that field's value class is.

謌踐踏愛綪 2024-07-30 07:41:55

SPField 类有许多派生类

例如,假设 Lookup 字段类型(使用 ID;#value)您可以检查 SPField.Type == SPFieldType.Lookup,然后将 SPField 转换为 SPFieldLookup 并使用其重写方法来获取记录值。

有关更多详细信息,请参阅自定义字段值类

另外 - 如果我没记错的话(我现在无法检查这一点,所以 DYOR)您可以在基本 SPField 对象上调用 .ValueAsText 和 .ValueAsHtml ,它将从值中删除 ID;# 。

The SPField class has many derived classed

For example assuming a Lookup field type (that uses the ID;#value) you can check SPField.Type == SPFieldType.Lookup and then cast SPField to SPFieldLookup and use its overriden methods to get the records value.

See Custom Field Value Classes for more details

Also - If I remember correctly (I can't check this right now so DYOR) you can call .ValueAsText and .ValueAsHtml on the base SPField object and it will remove ID;# from the values.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文