Recently while testing one of our old existing flows, we got the below error
Action ‘Create_Child_Log_Record’ failed: A record with matching key values already exists.
{
“error”: {
“code”: “0x80040237”,
“message”: “A record with matching key values already exists.”,
“@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionSourceKey”: “Plugin/Microsoft.Crm.ObjectModel.CustomBusinessEntityService”,
“@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepKey”: “38200c13-a28e-ee11-be36-002248933483”,
“@Microsoft.PowerApps.CDS.ErrorDetails.ApiDepthKey”: “1”,
“@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionMessageName”: “DuplicateRecord”,
“@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionHttpStatusCode”: “412”,
“@Microsoft.PowerApps.CDS.ErrorDetails.SqlExceptionMessage”: “Violation of PRIMARY KEY constraint ‘PK_childBase’. Cannot insert duplicate key in object ‘dbo.bew_logBase’. The duplicate key value is .”,
“@Microsoft.PowerApps.CDS.HelpLink”: “http://go.microsoft.com/fwlink/?LinkID=398563&error=Microsoft.Crm.CrmException%3a80040237&client=platform”,
“@Microsoft.PowerApps.CDS.InnerError.Message”: “Cannot insert duplicate key.”
}
}
Basically on Create or Update of the Parent Record it was creating a corresponding child log record, recording changes in the status field of the parent record.
The issue was in the Create Child Log record step, here it was setting the Primary Key Field / GUID field of the Child Log record being created with the GUID of the Parent record.
This worked for the 1st record, but when trying to create any new record with the same parent’s GUID, it was throwing the duplicate exception as it would be the same parent GUID getting specified.
On clearing that field, and letting the system generate the GUID, the flow ran successfully.
Hope it helps..
Discover more from Nishant Rana's Weblog
Subscribe to get the latest posts to your email.
One thought on “Fixed – Action Failed: A record with matching key values already exists (DuplicateRecord)– Power Automate / Dataverse”