How to associate Knowledge Article with Incident (Case) Programmatically in Dynamics 365

By | April 12, 2018

Introduction:

Microsoft has introduced a knowledge management system for Dynamics CRM 365. This enables users to create rich knowledge articles, which also supports embedding external multimedia content like images and videos in the form of links. It also allows translations and versioning for the articles.

In this blog will discuss about how to associate Knowledge Article with Incident (Case) programmatically.

Recently, we came across below scenario,

Where User has dropdowns of “Knowledge Article” and “Incident” and one custom button.

If user select values form dropdowns and clicked on the custom button then “Knowledge Article” should associate with selected “Incident”. But we cannot Associate Knowledge Article with Incident (Case) directly without creating custom relationships.

After some research and play around we found the below solution.

Solution:

We used OOB relationships to achieve this. In Dynamics CRM there is one intermediary entity called “Knowledge Article Entity” between Incident (case) and Knowledge Article.

“Knowledge Article Entity” entity have following 2 OOB relationships.

  1. Knowledge Article Entity -> Knowledge Article (N:1)
  2. Knowledge Article Entity -> Case (N:1)

How to associate Knowledge Article with Incident (Case) Programmatically in Dynamics 365

To perform above action, follow the below-mentioned steps:

Steps 1:

Create a new record or used existing record of Knowledge Article and Incident (Case) entity.

Steps 2:

Create new record on “Knowledge Article Entity” entity with following two value.

  1. Knowledge Article Lookup Value (step 1)
  2. Case Lookup Value (step 1)

Steps 3:

Associate newly created “Knowledge Article Entity” (created in step 2) entity record with Incident (case).

Refer the code below;

JavaScript Code:

 C# Code:

 

Conclusion:

Using solution described above the user can Associate Knowledge Article with Incident (Case) programmatically using OOB relationships in Dynamics 365.

Export Dynamics CRM Reports

Leave a Reply

Your email address will not be published. Required fields are marked *