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

Notifications

Announcements

No record found.

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,216 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,216 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,216 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,216 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 Super User 2025 Season 2 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 70

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans