Microsoft Knowledge Base Articles Authoring and Lifecycle on SharePoint


While Microsoft Dynamics CRM 2011 itself supports Microsoft Knowledge Base (KB) articles, there are much richer systems that support an end to end Content Management Life Cycle that includes Create/Edit/Review/Approval/Publish roles and responsibilities. In this post, we will illustrate how you could use such a system for KB content management while still making articles available in CRM 2011.

For the purposes of this post, we will use Microsoft SharePoint 2010 On-Premise as the Content Management System. We will focus on the integration points between the two systems rather than the content creation process. The configuration matrix for this solution will work is as follows:
 
 

CRM 2011 On-Premises

CRM 2011 Online

SharePoint 2010 On-Premise

Yes

Yes

The way this works is in two parts (i) Create your content in SharePoint (ii) Push the KB from SharePoint into CRM. Now, let’s look at each of these steps.

Content Creation in your SharePoint OnPremise

There are many ways of creating KB Articles on SharePoint since Rich Text Editing is available at many places (for example creation of site pages, wiki pages, blogs, etc.) For this solution, we want our articles created in SharePoint in a way that we can extract them with HTML styles intact so that they can directly be synced to CRM. A more complicated approach could extract style sheets, insert styles at the required places in the html and then push the content to CRM. For this blog, however, we have considered an approach that will directly embed the styles inside the html, keeping the solution simple by not requiring us to write any custom code.

How can we achieve this?

1. Create a custom list on SharePoint as shown below. To create a custom list, you will need to have Manage Lists Permissions.

clip_image002

2. Click on Create Column as shown below:

clip_image004

3. Create a column which will store the title of the KB Article.

clip_image006

4. Create a column which will store the KB Article content. Now, we want to have rich text editing enabled, so choose the type as Multiple Lines of text and in additional settings choose either Rich Text or Enhanced rich text as shown below:

clip_image008

5. This is one of many ways to create KB articles in SharePoint - you can have your own lifecycle/workflow for content creation as you get these KB articles ready for Publishing. Now, lets make an assumption that these KB articles are ready to publish to CRM.

Pushing KB Articles to CRM from SharePoint custom lists:

Now that the articles are ready, let’s look at how we can push them over to CRM. There are 2 parts we need to consider:

1. Reading a KB Article from a SharePoint custom list.

2. Creating an entry for it in CRM/Updating an existing KB entry

Reading a KB Article from a SharePoint custom list:

SharePoint provides various ways of reading a list and list items like the SharePoint Object Model, SharePoint Client Side Object Model (CSOM) and web services (List Web service).

I have used the List web service (Lists.asmx) in this example to read our custom list of KB Articles. The code is as follows:

ListWebReference.Lists ListService = new ListWebReference.Lists(); ListService.Credentials = new System.Net.NetworkCredential("username","password","domain"); ListService.Url = "http://manish_test1:5555/TestBlog1/_vti_bin/Lists.asmx"; // http://<your_site>/_vti_bin/Lists.asmx string kbContent = string.Empty; string title = string.Empty; XmlNode nodes = ListService.GetListItems("My Custom List","",null,null,"",null,""); foreach (System.Xml.XmlNode node in nodes) { if (node.Name == "rs:data") { for (int i = 0; i < node.ChildNodes.Count; i++) { if (node.ChildNodes[i].Name == "z:row") { kbContent = node.ChildNodes[i].Attributes["ows_RTEcol"].Value; title = node.ChildNodes[i].Attributes["ows_Title"].Value; } } } break; // for demo purpose, I'm taking just the first List Item. }

Now we have read a KB Article from the SharePoint Custom List and its title is present in title string and its contents are present in kbContent string.

The work which is remaining is to create a record for this article in CRM. You can automatically tie the push into CRM with a state change in SharePoint.

Creating a KB Article record in CRM:

We will use Organization service (Organization.svc) for this purpose. Add a service reference for Organization.svc in your project.

OrganizationServiceClient client = new OrganizationServiceClient(); // For CRM on-prem client.ClientCredentials.Windows.ClientCredential.Domain = "domain"; client.ClientCredentials.Windows.ClientCredential.UserName = "username"; client.ClientCredentials.Windows.ClientCredential.Password = "password"; // For CRM online client.ClientCredentials.UserName.UserName = "username"; client.ClientCredentials.UserName.Password = "password"; Entity kbArticle = new Entity(); kbArticle.Attributes = new OrgServiceReference.AttributeCollection(); // OrgServiceReference is the name given to the organization service reference kbArticle.LogicalName = "kbarticle"; //KB Template EntityReference kbArticleTemplate = new EntityReference(); kbArticleTemplate.LogicalName = "kbarticletemplate"; kbArticleTemplate.Id = new Guid("C3F93721-91B6-475A-ACD0-0A68AA1CB842"); //Give KB Article template id here, for whichever template you want to create your KB. //Subject EntityReference kbArticleSubject = new EntityReference(); kbArticleSubject.LogicalName = "subject"; kbArticleSubject.Id = new Guid("56270724-3BA5-4F5C-A84F-A8057B54286E"); //Give Subject Id here kbArticle.Attributes.Add(new KeyValuePair<string, object>("kbarticletemplateid", kbArticleTemplate)); kbArticle.Attributes.Add(new KeyValuePair<string,object>("title",title)); kbArticle.Attributes.Add(new KeyValuePair<string, object>("subjectid", kbArticleSubject)); kbArticle.Attributes.Add(new KeyValuePair<string, object>("description", "Some Description")); kbArticle.Attributes.Add(new KeyValuePair<string, object>("content", kbContent)); kbArticle.Attributes.Add(new KeyValuePair<string,object>("articlexml",GetArticleXml(kbContent))); client.Create(kbArticle); //Create the KB Article private string GetArticleXml(string kbContent) { // Create a new XML document that contains an article data element. XmlDocument document = new XmlDocument(); XmlElement articleData = document.CreateElement("articledata"); // Create the first section element that contains the article's content. XmlElement section0 = document.CreateElement("section"); XmlAttribute attribute = document.CreateAttribute("id"); attribute.Value = "0"; section0.Attributes.Append(attribute); XmlElement content = document.CreateElement("content"); /* Depending on your template, you can give KbContent to whichever * section you want to give. For example: you can have description in section 0 and KB Content in section1. * In this example, I am putting KB Content in section 0 itself since my template contains just 1 section */ content.AppendChild(document.CreateCDataSection(kbContent)); section0.AppendChild(content); articleData.AppendChild(section0); document.AppendChild(articleData); return document.InnerXml.ToString(); }

Conclusion

This code will create a record for the KB Article in CRM. You can also call SetState to change the KB article’s states like Approved, etc. to directly publish it. Your CRM users will now be able to view the rich KB articles natively. In all likelihood the content lifecycle will be controlled in the external system, so the flow we are illustrating is really one way to push from your Content Mgmt System to CRM 2011. Give this a shot, and let us know what you think.

Cheers,

Manish Arora

Comments (10)

  1. KB article Query says:

    If your articles are created in CRM, will they show in Sharepoint?

    Which is a better system to use when creating articles – Sharepoint or CRM?

  2. girimam@gmail.com says:

    @Kb article Query

    I hope I understood your first question correctly. Creating an article in CRM will not automatically copy it to Sharepoint. This blog contains a way to use Sharepoint as your method of creation of an article using its rich experience and then have a copy of it in CRM for native use.

    To answer your second question. Microsoft Dynamics CRM has a good experience while creating articles. But it has certain limitations. As mentioned in the article Microsoft Sharepoint is a richer system for creation of aricles. It supports an end to end life cycle for articles from 'Creation' process to 'Review' to its 'Publishing'. It also has support for different sites like wikis, blogs which has a great editing experience.

  3. girimam@gmail.com says:

    @Kb article Query

    I hope I understood your first question correctly. Creating an article in CRM will not automatically copy it to Sharepoint. This blog contains a way to use Sharepoint as your method of creation of an article using its rich experience and then have a copy of it in CRM for native use.

    To answer your second question. Microsoft Dynamics CRM has a good experience while creating articles. But it has certain limitations. As mentioned in the article Microsoft Sharepoint is a richer system for creation of aricles. It supports an end to end life cycle for articles from 'Creation' process to 'Review' to its 'Publishing'. It also has support for different sites like wikis, blogs which has a great editing experience.

  4. girimam@gmail.com says:

    @Kb article Query

    I hope I understood your first question correctly. Creating an article in CRM will not automatically copy it to Sharepoint. This blog contains a way to use Sharepoint as your method of creation of an article using its rich experience and then have a copy of it in CRM for native use.

    To answer your second question. Microsoft Dynamics CRM has a good experience while creating articles. But it has certain limitations. As mentioned in the article Microsoft Sharepoint is a richer system for creation of aricles. It supports an end to end life cycle for articles from 'Creation' process to 'Review' to its 'Publishing'. It also has support for different sites like wikis, blogs which has a great editing experience.

  5. girimam@gmail.com says:

    @Kb article Query

    I hope I understood your first question correctly. Creating an article in CRM will not automatically copy it to Sharepoint. This blog contains a way to use Sharepoint as your method of creation of an article using its rich experience and then have a copy of it in CRM for native use.

    To answer your second question. Microsoft Dynamics CRM has a good experience while creating articles. But it has certain limitations. As mentioned in the article Microsoft Sharepoint is a richer system for creation of aricles. It supports an end to end life cycle for articles from 'Creation' process to 'Review' to its 'Publishing'. It also has support for different sites like wikis, blogs which has a great editing experience.

  6. girimam@gmail.com says:

    I apologise for the multiple replies

  7. Can CRM article be restricted access? says:

    Good way to complete the CRM limitation. The remain concerns was the CRM kb articles no RBAC. Can CRM article be restricted access?

    I mean some articles were not allowed to be viewed for some role, but allowed for others?

  8. Manish Arora says:

    Since articles are still being stored in CRM after publishing, hence the existing CRM limitations related to security will be there, but if you choose to have articles just on SharePoint and directly use from there, then SharePoint provides ways to configure permissions for different document libraries. But this is currently not possible in CRM.

  9. Cindy McDonald says:

    Hi there

    Great solution.

    The above suggests create custom lists.

    I want to know if we will be able to sync directly if content is to be pushed from SP site pages, wiki pages, blogs etc.

    Thanks

    Cindy

  10. KB Articles says:

    If SharePoint is used to create KB articles, is their a search function within CRM that can tag certain keywords and pull up relevant articles?

Skip to main content