我有一个插件,能够在CRM中更新案例,但我现在想要它创建一个新的知识库文章,因为我不相信这是可能的自动化使用工作流程。该插件由解决案例时执行的工作流触发。
以下是我到目前为止所拥有的,但它不起作用:
Entity article = new Entity("kbarticle");
article["title"] = articleTitle;
article["subject"] = articleSubject;
service.Create(article);
Guid articleGUID = service.Create(article);
ColumnSet attributes = new ColumnSet(new string[] { "description" });
article = service.Retrieve(article.LogicalName, articleGUID, attributes);
article["description"] = articleDescription;
service.Update(article);发布于 2012-08-24 16:40:44
感谢你的回答,他们都帮助我朝着正确的方向找到了解决方案。主要的问题是我需要使用subjectid和模板的实体引用:
Entity kbarticle = new Entity("kbarticle");
kbarticle["title"] = title;
kbarticle["subjectid"] = new EntityReference(subject_LogicalName, subject_Guid);
kbarticle["kbarticletemplateid"] = new EntityReference(template_LogicalName, template_Guid);
service.Create(kbarticle);发布于 2012-08-23 23:53:47
一些事情..。
无效属性
article["subject"] = articleSubject;subject不是kbarticle实体的有效属性。subjectid是,但需要是有效主题记录的Lookup。我不能从你的片段中判断它是不是。
缺少属性
根据SDK,您还需要指定一个KB模板:
创建知识库文章时,必须将其与知识库模板和主题相关联...
剪辑
要将文章与模板相关联,请使用KbArticle。KbArticleTemplateId属性。要通过指定主题将文章放入特定类别,请使用KbArticle.SubjectId属性。
冗余码
而且,可能不是错误的来源,但是您的代码尝试创建文章两次。这里的第一行代码是多余的:
service.Create(article);
Guid articleGUID = service.Create(article);除此之外,我们确实需要知道您的代码引发的错误(尽管我怀疑这将是我的第一点)。
发布于 2012-08-21 21:50:18
你有没有看过这篇MSDN文章,它不是一个代码示例,但它描述了创建文章的步骤。
编辑:
您需要为我们提供更多的调试信息。任何一种;
您可能会发现,在Visual Studio中开发针对单元测试的文章创建代码会更容易,然后您可以稍后将其与工作流活动挂钩。
https://stackoverflow.com/questions/12055926
复制相似问题