Creating a knowledge base article using C# plugin

I am writing this post with complete code to help someone in the community who might be having a similar requirement. Please see the code below:

Entity ent = new Entity(“kbarticle”);
ent.Attributes.Add(“title”, <title>);
ent.Attributes.Add(“kbarticletemplateid”, new EntityReference(“kbarticletemplate”,new Guid(< Template Id >)));
ent.Attributes.Add(“subjectid”, new EntityReference(“subject”, new Guid(<Subject Id >)));

string articlexml = “<articledata><section id=’0′><content><![CDATA[“ + <<This is section 1 descriotion> > + “]]></content></section><section id=’1′><content><![CDATA[“ + <This is section 2 descriotion>  + “]]></content></section><section id=’2′><content><![CDATA[“ + <This is section 3 descriotion> + “]]></content></section></articledata>”;

ent.Attributes.Add(“articlexml”, articlexml);
Service.Create(ent);

Important points:

  • Description field is not the body of article. You will have to populate articleXML field
  • ArticleXML depends on the sections defined in your article template. In my case, I had 3 sections in the template.
  • Template ID and Subject ID are required to create articles in CRM

11 thoughts on “Creating a knowledge base article using C# plugin

Add yours

  1. This added stress to an already over stressed person could be the last straw in the momentum towards disease, pain and suffering; in other words,
    only unhealthy people get sick. Chiropractic care led to a faster healing process even if the
    cause of the injury has been brought by accidents or grave illnesses.
    by severe aches all over the body, disturbed sleep, inability to cope.

  2. A spruce sound board’s quality is NOT found in the
    tree that it came from, and never really was
    – and truly, not everyone prefers Adirondack Red
    Spruce or even German Silver Spruce. 7 or later, and once installed you will find that
    Quick – Time is now able to deal with a much wider selection of media formats, including Div –
    X. The best solution to this problem is to try an alternative media
    player, but you can also convert the Div – X file into a format
    that Quick – Time can play back, such as MOV; there is also
    the option of adding a Div – X player to Quick – Time.

Leave a comment

Create a website or blog at WordPress.com

Up ↑