如何在没有 WssId 的情况下处理未使用的托管元数据条款?
问题
我们使用 FrontPage RPC(放置文档 调用)将(大量)文件上传到 SharePoint。据我们所知,通过此协议设置分类字段的值需要它们的WssId。
问题是,除非之前在列表项上明确使用过术语,否则它们似乎没有 WSS ID。这会导致上传包含以前未使用过的元数据术语的文档失败。
代码
调用 TaxonomyField.GetWssIdsOfTerm 根本不返回这些术语的 ID。
SPSite site = new SPSite( "http://some.site.com/foo/bar" );
SPWeb web = site.OpenWeb();
TaxonomySession session = new TaxonomySession( site );
TermStore termStore = session.TermStores[new Guid( "3ead46e7-6bb2-4a54-8cf5-497fc7229697" )];
TermSet termSet = termStore.GetTermSet( new Guid( "f21ac592-5e51-49d0-88a8-50be7682de55" ) );
Guid termId = new Guid( "a40d53ed-a017-4fcd-a2f3-4c709272eee4" );
int[] wssIds = TaxonomyField.GetWssIdsOfTerm( site, termStore.Id, termSet.Id, termId, false, 1);
foreach( int wssId in wssIds )
{
Console.WriteLine( wssId );
}
我们还尝试直接查询分类隐藏列表,得到类似的结果。
呼救
关于如何解决这个问题的确认和建议将不胜感激。我看到了三种可能的解决方案:
- 改变我们的上传方式,要么以不同的方式上传条款,要么切换到不同的协议。
- 以不同的方式查询元数据 WssIds。适用于未使用的术语的一种。
- 编写/查找一个工具来预解析所有术语的 WssId。非常欢迎有关如何优雅地做到这一点的建议。
The Problem
We upload (large amounts of) files to SharePoint using FrontPage RPC (put documents call). As far as we've been able to find out, setting the value of taxonomy fields through this protocol requires their WssId.
The problem is that unless terms have been explicitly used before on a listitem, they don´t seem to have a WSS ID. This causes uploading documents with previously unused metadata terms to fail.
The Code
The call TaxonomyField.GetWssIdsOfTerm in the code snippet below simply doesn´t return an ID for those terms.
SPSite site = new SPSite( "http://some.site.com/foo/bar" );
SPWeb web = site.OpenWeb();
TaxonomySession session = new TaxonomySession( site );
TermStore termStore = session.TermStores[new Guid( "3ead46e7-6bb2-4a54-8cf5-497fc7229697" )];
TermSet termSet = termStore.GetTermSet( new Guid( "f21ac592-5e51-49d0-88a8-50be7682de55" ) );
Guid termId = new Guid( "a40d53ed-a017-4fcd-a2f3-4c709272eee4" );
int[] wssIds = TaxonomyField.GetWssIdsOfTerm( site, termStore.Id, termSet.Id, termId, false, 1);
foreach( int wssId in wssIds )
{
Console.WriteLine( wssId );
}
We also tried querying the taxonomy hidden list directly, with similar results.
The Cry For Help
Both confirmation and advice on how to tackle this would be appreciated. I see three possible routes to a solution:
- Change the way we are uploading, either by uploading the terms in a different way, or by switching to a different protocol.
- Query for the metadata WssIds in a different way. One that works for unused terms.
- Write/find a tool to preresolve WssIds for all terms. Suggestions on how to do this elegantly are most welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 WssID 值设置为 -1 应该会对您有所帮助。我在两个不同的 Web 应用程序之间遇到了类似的问题(复制包含元数据字段的文档)。我花了很多时间来解决奇怪的元数据问题。最后,将值设置为-1解决了我所有的问题。即使 GetWssIdsOfTerm 返回一个值,我也使用了 -1 并且它可以正常工作。
可能有一些后台逻辑会处理 WssId。
拉德克
setting the WssID value to -1 should help you. I had similar problem (copying documents containing metadata fields) between two different web applications. I've spent many hours on solving strange metadata issues. In the end, setting the value to -1 have solved all my issues. Even if the GetWssIdsOfTerm returns a value, I've used -1 and it works correctly.
Probably there is some background logic that will tak care of the WssId.
Radek