我正在尝试从Dynamics 365在线实例中检索kbarticle。我使用SDK示例提供的非常简单的查询,但它永远不会返回任何kbarticle。
以下是代码:
SearchByTitleKbArticleRequest searchByTitleRequest =
new SearchByTitleKbArticleRequest()
{
SubjectId = subjectId, // I have retrieved subjectid earlier.
UseInflection = false,
SearchText = "My Article",
QueryExpression = new QueryExpression()
{
ColumnSet = new ColumnSet(true),
EntityName = "kbarticle" // I've tried knowledgearticle as well.
}
};
var searchByTitleResponse = (SearchByTitleKbArticleResponse)
serviceProxy.Execute(searchByTitleRequest);
// check success
var retrievedArticles = searchByTitleResponse.EntityCollection.Entities;
Console . WriteLine ( " Results of search (titles found):" + retrievedArticles.Count ); // It is always 0
foreach ( var article in retrievedArticles )
Console . WriteLine ( article .Id );
有人能指出正确的方向让这条消息有效吗?
答案 0 :(得分:0)
这取决于您使用的实体,下面我给出了KnowledgeArticle的示例。
根据Search knowledge articles using full-text search,知识文章是全文索引并支持SQL Server全文搜索。
您可以使用FullTextSearchKnowledgeArticleRequest搜索文章。
var queryExpression = new QueryExpression("knowledgearticle")
{
ColumnSet = new ColumnSet(true),
PageInfo = new PagingInfo()
{
PageNumber = 1,
Count = 5,
}
};
FullTextSearchKnowledgeArticleRequest searchByTitleRequest =
new FullTextSearchKnowledgeArticleRequest()
{
UseInflection = true,
SearchText = "Error",
RemoveDuplicates = false,
StateCode = 0,
QueryExpression = queryExpression
};
var fullTextSearchKnowledgeArticleResponse = (FullTextSearchKnowledgeArticleResponse)
orgService.Execute(searchByTitleRequest);
// check success
var retrievedArticles = fullTextSearchKnowledgeArticleResponse.EntityCollection.Entities;
Console.WriteLine("Results of search (titles found):" + retrievedArticles.Count);
foreach (var article in retrievedArticles)
Console.WriteLine(article.Id);
请注意,在SQL上索引数据似乎需要一些时间,这可能不会使用FullTextSearchKnowledgeArticleRequest返回新创建的文章。