AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 12.03.2011, 02:16   #1  
Blog bot is offline
Blog bot
Участник
 
25,617 / 848 (80) +++++++
Регистрация: 28.10.2006
Microsoft Dynamics CRM Team Blog: Microsoft Knowledge Base Articles Authoring and Lifecycle on SharePoint
Источник: http://blogs.msdn.com/b/crm/archive/...harepoint.aspx
==============

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.



2. Click on Create Column as shown below:



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



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:



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, let’s 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:///_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<span class="kwrd"string/span, span class="kwrd"object/span>("kbarticletemplateid", kbArticleTemplate)); kbArticle.Attributes.Add(new KeyValuePair<span class="kwrd"string/span,span class="kwrd"object/span>("title",title)); kbArticle.Attributes.Add(new KeyValuePair<span class="kwrd"string/span, span class="kwrd"object/span>("subjectid", kbArticleSubject)); kbArticle.Attributes.Add(new KeyValuePair<span class="kwrd"string/span, span class="kwrd"object/span>("description", "Some Description")); kbArticle.Attributes.Add(new KeyValuePair<span class="kwrd"string/span, span class="kwrd"object/span>("content", kbContent)); kbArticle.Attributes.Add(new KeyValuePair<span class="kwrd"string/span,span class="kwrd"object/span>("articlexml",GetArticleXml(kbContent))); client.Create(kbArticle); //Create the KB Articleprivate 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







Источник: http://blogs.msdn.com/b/crm/archive/...harepoint.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 11:12.