51

I've just spent several hours trying to fix a deployment that was failing with the following extremely helpful error message:

Error: objects/Opportunity.object(2098,13):duplicate value found: <unknown> duplicates value on record with id: <unknown>

After a lot of Googling (which didn't help) and even more trial and error (which finally did), I've discovered that the question I really needed an answer to is...

If Salesforce gives me a "duplicate value found: <unknown> duplicates value found on record with id <unknown>", how can I figure out what's actually gone wrong?

There are several possible answers online, and a couple here on StackExchange, but without knowing how to narrow the focus after getting such a horrible, useless error message, it's too easy to fall for red herrings.

16 Answers 16

81

My condolences if you're reading this, because it means that you're being tortured by an extremely useless and vague error message. Let's see if we can get through this without tearing out too much hair. :-)

Deployment Error or DML Error?

If you Google "duplicate value found: <unknown>...", the results you get will cover a wide variety of root causes. The first step is to figure out which scenario is appropriate to you.

DML Error

If you're getting this error from a DML operation, you're in luck. The possible solutions seem to be more straightforward. Sometimes, there might even only be one "<unknown>" instead of two to deal with.

Here are a few of the better posts for the DML-based errors:

Basically, it looks like the problem boils down to fields with unique constraints. Daniel's blog post does a great job of breaking down the debug process.

Deployment Error

If you're getting this error while trying to deploy metadata, things are a bit tougher.

Debugging deployment errors is almost always painful in some way, but this particular error message with its two vague "<unknown>" references is especially cruel. The following steps can help to quickly get you on the right track to finding a solution.

Step One: Identify the Problem

This step is easy to start, but sometimes difficult to finish. Take a look at the error message, and I'll explain what I mean.

Error: objects/Opportunity.object(2098,13):duplicate value found: <unknown> duplicates value on record with id: <unknown>

Clearly the Opportunity object metadata I'm trying to deploy is causing a problem. Don't start Googling yet, though. There's more for you to learn about what, exactly, is failing.

Forget about the error "message" for a moment, and focus on the error location.

Error: objects/Opportunity.object(2098,13)... 

The important bit here is (2098,13). This is the line and column number inside the Opportunity.object metadata file where the trouble is coming from.

Here's what my file looks like near that line...

Inspecting the Opportunity.object metadata file

This tells me that the error seems to be specifically related to the StageName picklist field that I'm trying to deploy.

Important: If this is EXACTLY the problem you're having, skip to the end to see a potential solution.

Step Two: Isolate the Problem

Deployments are tricky, complicated things with many dependencies to contend with. When debugging metadata errors that are not related to Apex code, simplify things by removing everything from your deployment package except the component that's giving you trouble (and its direct dependencies, of course).

If you're still getting the error after doing this, then you've successfully started the process of isolating the problem. In my case, I can try to Isolate things further by removing the entire StageName field and re-trying my deployment.

After removing that field, my deployment finally succeeds! This conclusively proves that something I'm pushing in the StageName field is causing the error.

Remember, this example is ONLY relevant to my situation. The metadata components that are giving you trouble will most likely have different names, be different types, etc. This is just an example.

Step Three: Start Digging

Now that I've conclusively isolated the problem to a particular field on a specific object, I can start digging deeper. Here's what I've found to be the most common possible causes.

For Picklist Fields...

If you've narrowed things down to a problem with a Picklist field, make sure that your target org does not already have an inactive picklist field with the same name as one of the ones you are trying to deploy.

If this is the case, you'll need to delete the picklist value. Once you do this, your deployment should proceed (until the next error sneaks up on you, of course).

For Other Problems...

If your problem is not related to a picklist field, the general consensus seems to be that there are some strange situations that come up if Field History Tracking is enabled on the object that is giving you trouble.

Here are the best solutions I've found related to "Field History Tracking" being a possible issue.

Conclusion

Debugging Salesforce errors is never fun. It's especially not fun when the error messages are vague, like the unhelpful "duplicate value found: <unknown>..." error message. This post has provided a framework for debugging this type of error, whether it came from a DML or a metadata deployment operation.

The steps from the "Deployment Error" section are useful for debugging other types of non-code deployment related errors. Hopefully you've found them useful. As time goes by, if additional "flavors" of this error show up, I'll update this answer to include them. Good luck out there!

3
  • 3
    progress of issue: success.salesforce.com/issues_view?id=a1p30000000T5hTAAS
    – kurunve
    Feb 1, 2016 at 11:16
  • 4
    If only we had someone internal in Salesforce who could champion improving this error message! ;) Feb 11, 2018 at 22:30
  • For me, it wasn't duplicate rule related. I ended up having to move the DML of an Account record from a separate unit test up to the testSetup method. Oddly enough, I've had to do the exact opposite in another occasion. I debugged all the account values in my unit test and checked that the unique fields had unique values (which they did). So i'm still none the wiser as to why this issue was being hit. There are no declarative automations (process builder, workflow rule, flow) which is updating a unique field to have a non-unique value either. Oct 19, 2022 at 11:13
5

After many hours trying to look for every single issue mentioned on this page, and getting so angry about the lack of useful error messages in DX I was reminded that deployment settings may give more info.

The error I was getting in DX was just N/A duplicate value found: <unknown> duplicates value on record with id: <unknown>. The Path was just showing as N/A.

However, when I go into Deployment Settings in the org, the API Name is shown.

The Error in Deployment Settings - shows me the duplicate Now, I think I know why the Path showed N/A in this instance, because the source was stuffed up due to a report being duplicated. I had created the report in Public Folders, pulled the source, then moved the report to an existing folder, and pulled the source again. See the Issue 165 in the CLI Github and the related issue. I was able to use the workaround mentioned to fix my source and then deploy.

I hope this trick of trying to find the error helps someone else.

3

Known issue : Deployment fails with duplicate value found: duplicates value on record with id: error

I hope this might help : If you are facing this error for page layouts, here is the best workaround !

Workaround Solution :

  1. Quick Actions for either salesforce classic or lightning, buttons on related lists may be showing duplicates, which should not be. (Observe the entire page layout for duplicates)
  2. Removing them and saving from the source environment doesn't work (duplicates re appear after saving).
  3. Retrieve via ant and edit retrieved page layout file to eliminate duplicates manually.
  4. Deploy the retrieved & modified file from your local to Target environment.

    Known issue : Deployment fails with duplicate value found

1
  • I had issue #1, which you could see when you did "View Source" from the inbound change set for the failing component. It was marked with an ID that began with '09l'. Apr 5, 2019 at 18:26
2

I ran into this issue on a Lookup field where it had the "Business Status" Field set to "Active" in the metadata. I was thrown off by the winter fix as it had a lookup filter.

I removed the Active from the field-meta.xml and that solved it for me.

2

I was running into this error for a LWC new component deployment and spent hours trying to figure out. Finally, have a workaround. Whenever I need to deploy, I simply make fake changes in the .html file and for some reason it deploys fine.

Like, add a blank once, next deployment remove that div... each time I deploy for any change in the java-script component.

1
  • This annoyingly helped unblock me; not sure why, but it works! Jun 30, 2022 at 12:19
1

For me this error appeared while trying to deploy a class that I previously deleted and readded. The thing was that the delete failed to execute completely. I fixed it by deleting the class again and refreshing the metadata.

If you are stuck you can always try delete -> refresh -> create again.

1

I just wanted to add that this can come up via Salesforce DX as well. The specific scenario was, we spent some weeks developing a project in Developer Edition scratch orgs, and then I changed it to use Partner Developer Edition instead. The Partner DE orgs came with Chatter disabled and so pushing the prior metadata threw this error on a few pieces of metadata including profiles and layouts.

1

For me, I had a Sales Process (businessProcess) in the force-app directory of a project that is going to be a 2GP and installed in prod, but for our testing sandbox, we deploy the source, not install a package version. The record type was already in the sandbox outside of a package. We've decided to not package the businessProcess in the 2GP, but put it in the force-scratch-only part. Worked like a charm.

NOTE! force-scratch-only stuff is fine with referencing stuff from force-app (force-app deploy happens before...), but force-app stuff is NOT fine with referencing things that are deployed in force-scratch-app. @vivek's article about sfdx paths is AMAZING https://salesforce.stackexchange.com/a/206910/1014

0

If you're dealing with this issue and the error is referencing a flow, I recommend taking a close look at this issue of overwriting existing flows/processes in the target org, as mentioned here:

Getting an error that a flow "was" activate and cannot be overwritten

It may be helpful to use ant instead of change-sets to get more granular error messages to help you narrow down the exact issue.

These steps helped me resolve this issue when attempting to deploy a change-set and this ambiguous error message popped up regarding a flow.

0

I ran into this issue tonight (post Winter'19) when trying to create an Apex Class via the Developer Console (File > New > Apex Class). Unbeknownst to me, the class already existed (from a managed packaged I had installed some time ago).

0

I was updating a picklist field in an Account and got this error. I then used the Workbench to perform the same update: success! Refresh of the Account page layout and yes, my update had indeed been successful.

Very strange.

0

I encountered this issue deploying an LWC from a fresh SFDX project and have some insight that may be useful to someone while troubleshooting.

My SFDX project is located at the following path: (notice the folder named tinkers)

C:\Users\myUserName\Desktop\lwc\tinkers\math\math

I created an LWC locally and tried to deploy it to the server. It failed with this message:

=== Deploy Errors
PROJECT PATH  ERRORS                                                                                  
────────────  ────────────────────────────────────────────────────────────────────────────────────────
              duplicate value found: <unknown> duplicates value on record with id: <unknown>          
              Unable to build Lightning Component source for markup://c:tinkers: Invalid suffix: json.

The part I found interesting is the reference to:

markup://c:tinkers

No component by than name exists and the only time the string "tinkers" is ever used is in the name of a folder in the path to get to the the SFDX project. This definitely seems like a core issue with the CLI.

UPDATE: More interesting findings

I used the metadata api to push my LWC to the salesforce server. After the successful deployment, I decided to try a SFDX retrieve and the mysterious references to "tinker" continues.

=== Retrieve Warnings
FULL NAME  TYPE                      MESSAGE                                                                  
─────────  ────────────────────────  ─────────────────────────────────────────────────────────────────────────
tinkers    LightningComponentBundle  Entity of type 'LightningComponentBundle' named 'tinkers' cannot be found

My observations/findings suggest that the SFDX CLI is having some issues navigating the path while trying to identify the component.

0

One of the possible issues, which I've not yet seen in all answers so far is when using an Auto Number field as a unique constraint, such as a Workflow copying the value of an auto number field into a unique text field used as an external ID. Most of the time it works fine, but I've seen this error happening in tests, when the auto number doesn't increment correctly and the number collides with an existing record (despite seeAllData is false).

0

I had the same issue but when deploying an LWC flow screen. I resolved this by using the terminal to deploy like in this post. The trace showed the deployment was successful.

Deploy lightning web component is getting failed with error - "--json --loglevel fatal ended with exit code 1"

-1

In case it's helpful for future readers, I countered this issue while trying to deploy a Lightning Web Component. When I tried to deploy while the JS file was open in VS code, the error appeared, but when I tried deploying while the HTML tab was open instead, the error didn't occur and the LWC was deployed successfully. Silly, and I don't know why, but it worked.

-2

Some instances of this issue were resolved in Winter 19. As of Spring 21, it seems to be recurring in some cases.

4
  • Good to know they are serious about this. This is helpful Jul 5, 2018 at 8:03
  • 3
    No it hasn't. I am currently working in a Spring'21 sandbox and I am seeing this very error. Jan 13, 2021 at 10:05
  • I am seeing in a recently refreshed sandbox too Apr 7, 2021 at 10:46
  • Summer'22 sandbox and still a problem. Updating a picklist value of an account generates this error. Updating some other field of the same account: no problem. Account has one unique field (which is always filled upon creation and never changed afterwards), which is not one of the updated fields. Validation rules: nope. Very, very strange. Aug 3, 2022 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .