SharePoint 列表 - 复制 SPListItem ID

发布于 2024-09-13 06:20:22 字数 621 浏览 5 评论 0原文

我有一个解决方案,将 SharePoint 列表的所有内容复制到一个文件,然后将文件的内容复制回 SharePoint(用于备份和阶段/实时环境切换)。

现在我可以复制我需要的所有字段,除了一个:ID

我知道它是一个只读字段,但其他一些只读字段可以更新(根据我测试的创建、作者、修改、编辑器、_ModerationStatus 和 _ModerationComments )

我无法使用 CopyTo 方法,因为我无法访问目标列表。

我希望能够保留 ID,因为我不想破坏所有 http ://siteCollection//Lists/Posts/Post.aspx?ID=... 出现在我的网站内容中的 URL。

所以基本上,只要列表中没有删除任何内容,我现在拥有的系统(推送除 ID 之外的所有内容)就可以正常工作。当某些内容被删除时(例如 ID = 1),第一个项目将变为 ID=2,当我将其推入空目标列表时,它会变为 ID=1。

有没有办法强制为 SPListItem 提供 ID?这几乎肯定是黑客攻击,但也许有人有办法?

谢谢!

I have a solution that copies all the content of SharePoint lists to a file, and then copies the content of the file back onto SharePoint (used for backups and stage / live environment switches).

Now I can copy all the fields I need except for one : ID

I understand that it is a read only field, but some other read only fields can be updated (Created, Author, Modified, Editor, _ModerationStatus and _ModerationComments from what I have tested)

I can't use the CopyTo method because I cannot access the destination list.

I want to be able to keep the IDs because I don't want to break all the http://siteCollection//Lists/Posts/Post.aspx?ID=... URLs that appear all over the content of my website.

So basically, the system I have now (which pushes everything besides the ID) works well, as long as nothing gets deleted from the list. When something gets deleted (say ID = 1) the first item becomes ID=2 and when I push it in the empty destination list, it becomes ID=1.

Is there a way to force an ID for a SPListItem? It would almost definitely be a hack, but maybe someone has a way?

Thanks!

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

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

发布评论

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

评论(2

再可℃爱ぅ一点好了 2024-09-20 06:20:22

好吧,如果你只是想要这个,为什么不创建 ID=1 的虚拟项目然后删除它呢?添加这个逻辑应该不会太难

Well, if you just want that, why not create dummy item with ID=1 and then delete it? it should not be too difficult to add this logic

入画浅相思 2024-09-20 06:20:22

内容部署和迁移 API 允许您执行此操作。

我首先要看的是 Gary Lapointe STSADM 扩展 作为他在扩展内置命令方面做了一些出色的工作,包括 保持原始 GUID 完整的导入

There might be something in the Content Deployment and Migration API to allow you do do this.

The first thing I would look at though is Gary Lapointe STSADM extensions as he's done some great work on extending the built in commands including imports that keep original GUID's intact.

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