Using System;
Using MICROSOFT.XRM.SDK;
Using Microsoft.Crm.Sdk.Messages;
Using Microsoft.Xrm.Sdk.Query;
<summary>
Knowledge Base Articles
</summary>
public class Kbarticlehelper
{
public static readonly String entityname = "Kbarticle";
Public Guid Kbarticleid = Guid.Empty;
public Iorganizationservice Service;
<summary>
Create a Knowledge Base article
</summary>
public void Create ()
{
Entity en = new entity () {logicalname = entityname};
en["title" = "Knowledge Base article test";
Kbarticleid = service. Create (en);
}
<summary>
Retrieves the first 10 KB articles for a specified product
</summary>
<param name= "ProductId" > Product id</param>
public void Retrievebytopincidentproductkbarticle (Guid productId)
{
Retrievebytopincidentproductkbarticlerequest request = new Retrievebytopincidentproductkbarticlerequest ();
Request. ProductId = ProductId;
Retrievebytopincidentproductkbarticleresponse response =
(retrievebytopincidentproductkbarticleresponse) service. Execute (Request);
Entitycollection entitycollection = Response. Entitycollection;
}
<summary>
Retrieves the first 10 knowledge Base articles for a specified topic
</summary>
<param name= "Subjectid" > Theme id</param>
public void Retrievebytopincidentsubjectkbarticle (Guid subjectid)
{
Retrievebytopincidentsubjectkbarticlerequest request = new Retrievebytopincidentsubjectkbarticlerequest ();
Request. Subjectid = Subjectid;
Retrievebytopincidentsubjectkbarticleresponse response =
(retrievebytopincidentsubjectkbarticleresponse) service. Execute (Request);
Entitycollection entitycollection = Response. Entitycollection;
}
<summary>
Finds all document indexes in the body that include the specified text
</summary>
<param name= "Query" > Query criteria </param>
<param name= "Text" > Specify text </param>
<param name= "Subjectid" > Theme id</param>
public void Searchbybodykbarticle (querybase query,string text,guid Subjectid)
{
Searchbybodykbarticlerequest request = new Searchbybodykbarticlerequest ();
Request. queryexpression = query;
Request. Useinflection = true;
Request. SearchText = text;
Request. Subjectid = Subjectid;
Searchbybodykbarticleresponse response = (searchbybodykbarticleresponse) service. Execute (Request);
Entitycollection entitycollection = Response. Entitycollection;
}
<summary>
Finds all document indexes that include the specified keyword
</summary>
<param name= "Query" > Query criteria </param>
<param name= "Text" > Specify text </param>
<param name= "Subjectid" > Theme id</param>
public void Searchbykeywordskbarticle (querybase query, string text, Guid Subjectid)
{
Searchbykeywordskbarticlerequest request = new Searchbykeywordskbarticlerequest ();
Request. queryexpression = query;
Request. Useinflection = true;
Request. SearchText = text;
Request. Subjectid = Subjectid;
Searchbykeywordskbarticleresponse response = (searchbykeywordskbarticleresponse) service. Execute (Request);
Entitycollection entitycollection = Response. Entitycollection;
}
<summary>
Find all document indexes that include the specified text in the header
</summary>
<param name= "Query" > Query criteria </param>
<param name= "Text" > Specify text </param>
<param name= "Subjectid" > Theme id</param>
public void Searchbytitlekbarticle (querybase query, string text, Guid Subjectid)
{
Searchbytitlekbarticlerequest request = new Searchbytitlekbarticlerequest ();
Request. queryexpression = query;
Request. Useinflection = true;
Request. SearchText = text;
Request. Subjectid = Subjectid;
Searchbytitlekbarticleresponse response = (searchbytitlekbarticleresponse) service. Execute (Request);
Entitycollection entitycollection = Response. Entitycollection;
}
<summary>
Delete a knowledge Base article
</summary>
public void Delete ()
{
Service. Delete (EntityName, Kbarticleid);
}
}
CRM Operations Knowledge Base article entity