具有查找字段的 SharePoint 列表项目 - 移动/复制到不同的网站集
这是场景。我们的 SharePoint 自定义作业存档列出项目(基于某些标准)并将项目复制/移动到不同的网站集。在这种情况下,如果列表项有一些查找字段,当我复制/mpve 到不同的网站集时如何保留这些字段?
谢谢, 杜尔加
Here is the scenario. Our SharePoint custom job archives list items (based on ceratin crteria) and copies/moves the items to a different site collection. In this scenario, if the list item has some lookup fields, how do preserve these when I copy/mpve to different site collection?.
Thanks,
Durga
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查找字段的内部名称应保持相同,并且只要查找字段引用的列表使用相同的值(ID 可以不同,只需匹配该值并创建新的 SPFIeldLookupValue),就没有问题。根据字段内部名称复制元数据,一切都会顺利,我们使用计时器作业对新闻项目和文档进行同样的操作。
The lookup field's internal name should stay the same, and as long as the list the lookup field is referencing is using the same values (ID's can be different, just match the value and create a new SPFIeldLookupValue), there is no problem. copy metadata based on field internal names and everything should go fine, we do the same for archiving news items and documents using timerjobs.
您无法将字段从 sitecoll A“复制”到 sitecoll B,您必须重新创建它。通常的方法是实际使用创建查找字段的功能,但我想这里的情况并非如此(应该在一开始就完成,将来我建议这就是您创建字段的方式,看看如何方法可重复使用)。
您需要做的是在 b sitecoll 的 SPSite 对象中使用原始 Field 的
field.SchemaXml
创建一个新字段,这样您就可以获得从头开始重新创建字段的所有相关信息赛特科尔湾如果要设置新字段的内部名称,则需要使用 SPSite.Fields 集合的AddFieldAsXml
,因为 InternalName 属性是只读的。请阅读此处如何
检查字段是否存在:
you can't "copy" a field from sitecoll A to sitecoll B, you have to recreate it. The usual way to go about this is to actually use a feature that creates the lookup field, but that's not the case here I guess (should have been done at the start, in the future i suggest that's how you create fields, seeing how that method is reusable).
What you would need to do is in the SPSite object of the b sitecoll create a new field, using the original Field's
field.SchemaXml
, this way you have all relevant info to recreate the field from scratch in the sitecoll b. you need to use theAddFieldAsXml
of the SPSite.Fields collection if you want to set the internalname of the new field since the InternalName property is read only.Read how here
CHeck if field exist: