web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Error while creating Knowledge Article record programmatically

(0) ShareShare
ReportReport
Posted on by 275

Hello,

I am trying to create Knowledge Article record and getting below error:

{"error":{"code":"0x80040237","message":"A record with matching key values already exists.",
"@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionSourceKey":
"Plugin/Microsoft.Crm.Service.ObjectModel.KnowledgeArticleService",
"@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepKey":"2c33e9b7-ac2e-4dcc-8e73-a8cbc0eab812",
"@Microsoft.PowerApps.CDS.ErrorDetails.ApiDepthKey":"1",
"@Microsoft.PowerApps.CDS.ErrorDetails.ApiActivityIdKey":"5405f633-dc70-4be4-b17e-722a0c777e66",
"@Microsoft.PowerApps.CDS.ErrorDetails.ApiPluginSolutionNameKey":"System",
"@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepSolutionNameKey":"System",
"@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionCategory":"ClientError",
"@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionMessageName":"DuplicateRecord",
"@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionHttpStatusCode":"412",
"@Microsoft.PowerApps.CDS.ErrorDetails.SqlExceptionMessage":"Violation of UNIQUE KEY constraint 'ndx_KnowledgeArticleBase'.
Cannot insert duplicate key in object 'dbo.KnowledgeArticleBase'. The duplicate key value is <redacted>.",
"@Microsoft.PowerApps.CDS.HelpLink":"go.microsoft.com/.../
Microsoft.Crm.CrmException%3a80040237&client=platform",
"@Microsoft.PowerApps.CDS.InnerError.Message":"Cannot insert duplicate key."}}

Has anyone faced this before?

Thanks,

Mridula

I have the same question (0)
  • meelamri Profile Picture
    13,218 User Group Leader on at

    Hi,

    Please share your code ..

  • Mridula Profile Picture
    275 on at

    hi Mehdi,

    var data =

       {

           "st_products": sessionStorage.getItem("ProductValue"),

           "title": sessionStorage.getItem("Title"),

           "content": content

       }

       // create account record

       Xrm.WebApi.createRecord("knowledgearticle", data).then(

           function success(result) {

           },

           function (error) {

           }

       );

    pastedimage1627288588428v1.png

    st_products is a custom multi select optionset value.

    The above error which I am getting is random, if I run the same set of records again and again, it creates KA's and sometimes(randomly) throw error.

    I have 50+ KA's with same title and content.

    Thanks,

    Mridula

  • meelamri Profile Picture
    13,218 User Group Leader on at

    Do you have any alternate keys for the entity Knowledge Article?

  • Mridula Profile Picture
    275 on at

    No.

  • meelamri Profile Picture
    13,218 User Group Leader on at

    I can't reproduce this issue on my environment.  Could you test the same code without the "st_products" attribute ?

  • Mridula Profile Picture
    275 on at

    Hi Mehdi,

    Are you trying to create multiple KA's and running the code again to create same ones?

    Thanks,

    Mridula

  • Mridula Profile Picture
    275 on at

    Hi Mehdi,

    I tried commenting st_products custom field. Still facing same issue.

    pastedimage1627291548263v1.png

  • meelamri Profile Picture
    13,218 User Group Leader on at

    Are you trying to create multiple KA's and running the code again to create same ones?

    --> No, How do you create multiple KA ?

  • Mridula Profile Picture
    275 on at

    calling createKnowledgeArticles function with same title and content again and again.

    While doing so, its throwing error. But not sure which is the field considered as duplicate by KA.

    P.S. I have 50+ KA's with same title and content. So considering this, thinking title and content cannot be unique fields.

  • Amit Katariya007 Profile Picture
    10,409 Moderator on at

    Can you check the duplicate detection rules. Because when you create anything manually and if it is a duplicate then you can ignore the warning manually but when you try same thing with code/customization, then probablu system will not allow this creation.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 98 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 72

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans