使用内容数据库更新内部名称
目前,我们有一个字段的 ID 错误。 Sharepoint 字段的 ID 和内部名称在域模型上是只读的。我想知道是否有办法甚至通过使用内容数据库来更新它们。
一种可靠的方法是删除该字段并重新创建它。但它已经有数据了,而且有数千页。我想知道是否有一种方法可以只更新 ID 和内部名称,而不需要删除和重新创建字段。
谢谢
We currently have a field which has the wrong ID. the IDs and Internal Names of Sharepoint Fields are readonly on the domain model. I was wondering if there is a way to update them even by using the content database.
One sure way is to delete the field and recreate it. but it already has data and there are thousands of pages. I was wondering if there is a way just to update the IDs and Internal Name without doing the dropping and recreation of fields.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
即使它可能有效,也不要这样做。
它是:
使用某些脚本重新创建字段来保存数据更安全。
Even if it may work, don't do it.
It's:
Recreating the field using some script to keep data is safer.
我们遇到了同样的问题。搞乱数据库对我们来说不是一个选择(也不应该适合您),但您可以解决它。不幸的是,需要触摸每个页面才能更新元数据。
首先,创建列,就像它应该在列表中一样。然后,您可以通过多种方式将数据从旧列复制到新列:
老实说,编写一个小型控制台应用程序将是最快的。例如:
此外,强烈建议首先在开发环境中尝试此操作。只需从生产环境执行 STSADM 恢复并测试您的控制台应用程序即可。然后,验证您的数据并删除旧列!
We ran into the same problem. Messing with the DB was not an option for us (and shouldn't be for you either), but you can work around it. Unfortunately, it will require touching each page to update the metadata.
First, create the column like it should be in the list. Then, you can copy the data from the old column to the new column in a variety of ways:
Honestly, writing a small console app will be the quickest. For example:
Also, it would HIGHLY recommend trying this in a DEV environment first. Just do an STSADM restore from your production environment and test your console app. Then, validate your data and delete the old column!
我不建议修改内容数据库,因为它是:
您可以尝试做什么 - 查看内部名称属性实际上是“只读”还是被定义为“朋友”,并且您无法从不同的代码程序集中调用它。如果是后一种情况,您可以使用.Net反射来设置属性值。有关详细信息,请参阅此 MSDN 文档链接。
I would not suggest modifying the content database, since it is:
What you can try to do - see if the internal name property is actually "read only" or it is defined as "friend" and you cannot call it from a different code assembly. If it's the latter case, you can use .Net reflection to set the property value. See this MSDN documentation link for details.