1
votes

I am trying to retrieve a kbarticle from Dynamics 365 online instance. I use a very simple query provided by SDK sample but it never returns any kbarticle.

Below is the code:

 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 );
  1. In the new version of SDK, kbarticle is renamed to knowledgearticle. I have tried using knowledgearticle with no luck.
  2. The connection to the CRM Online instance is also correct and I am able to run other queries with RetrieveMultiple service.
  3. The article is published and I have also permissions to access the article.
  4. I am able to retrieve the same article using REST and also using RetrieveMultiple, so I don't see any issue in the article or my connection.

Can anyone point me to the right direction to make this message working?

1
did you try UseInflection=true & some article body text for search? Your current filter will search for exact Title if am not wrong..Arun Vinoth - MVP
Hello Arun, I have used UseInflection=false. and the article has text in the body. I tried other SDK messages such as SearchByKeyword or FullTextSearch. I have tried all possible/different combinations.Interface Mirror

1 Answers

0
votes

This depends on which entity you are using, below I'm giving the example for KnowledgeArticle.

Accordingly to Search knowledge articles using full-text search, the Knowledge Article are full-text indexed and support SQL Server full-text search.

You can use the FullTextSearchKnowledgeArticleRequest to search the articles.

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);

Note, there seems to be some time needed for the data to be indexed on SQL, which might not return a newly created article using the FullTextSearchKnowledgeArticleRequest .