function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ehartyeehartye 

Insert failed. <unknown> duplicates value on record with id: <unknown>

I got this error trying to deploy some test code: 

 

System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on record with id: <unknown>

 

Is anyone familiar with this? 

Best Answer chosen by Admin (Salesforce Developers) 
ehartyeehartye
figured out my own issue. I just realized that I was reusing some test code from another project and had already created categories for the inserted solutions, hence the duplicates. False alarm!

All Answers

Richie DRichie D

Hi ehartye,

 

For your test method do you insert some data to test? If you are running your tests on a clean system (or as part of a deployment of a package) then your tests will fail if you are expecting data that doesn't exist.

 

I expect that you are trying to load a data item and compare against another; both of which probably don't exist.

 

If not then perhaps you could post your code and then maybe someone can help you out. 

 

Regards,

Rich. 

ehartyeehartye

Thanks for the reply. You are certainly welcome to take a look:

 

Test Method:

 

static testMethod void testSolution(){ //First, prepare 20 solutions for the test data Solution[] SolutionsToCreate = new Solution[]{}; for(Integer x=0; x<20;x++){ Solution s = new Solution(SolutionName='test',SolutionNote='test'); SolutionsToCreate.add(s); } Case[] CasesToCreate = new Case[]{}; for(Integer x=0; x<20;x++){ Case c = new Case(Subject='test',Description='test',Feature_Area__c='Alarms',Status = 'PCR Submitted'); CasesToCreate.add(c); } //Now insert data causing solution triggers to fire. Test.startTest(); insert casesToCreate; insert solutionsToCreate; CategoryData[] CategoryDatasToCreate = new CategoryData[]{}; for(Integer x=0; x<20;x++){ CategoryData cs = new CategoryData(RelatedSobjectId=SolutionsToCreate[x].id,categorynodeid='02n80000000EP8ZAAW'); CategoryDatasToCreate.add(cs); } insert CategoryDatasToCreate; CaseSolution[] CaseSolutionsToCreate = new CaseSolution[]{}; for(Integer x=0; x<20;x++){ CaseSolution cs = new CaseSolution(CaseId=CasesToCreate[x].id,SolutionId=SolutionsToCreate[x].id); CaseSolutionsToCreate.add(cs); } insert caseSolutionsToCreate; for(Integer x=0; x<20;x++){ SolutionsToCreate[x].isPublished = true; } update SolutionsToCreate; Test.stopTest(); }

 Solution category method:

 

public static void AssignSolutionCategory(solution[] solutions) { Map<Id,string> solutionCaseMap = New Map<Id,string>(); List<string> solutionIdList = New List<string>(); for (CaseSolution cs : [Select SolutionId,CaseId from casesolution where SolutionId in :solutions]) { //I do this to ensure I only have one case match per solution if (solutionCaseMap.containsKey(cs.SolutionId)==false) { solutionCaseMap.put(cs.SolutionId,cs.CaseId); solutionIdList.add(cs.SolutionId); } } If (solutionCaseMap.size() > 0) { Map<Id,string> caseFeatureAreaMap = New Map<id, string>(); for (Case c : [Select Id,Feature_Area__c from case where id in (Select CaseId from casesolution where SolutionId in :solutionCaseMap.keySet())]) { caseFeatureAreaMap.put(c.id, c.Feature_Area__c); } List<CategoryNode> categoryNodeList = New List<CategoryNode>(); for (CategoryNode cn : [Select Id,MasterLabel from categorynode]) { categoryNodeList.add(cn); } List<CategoryData> category = New List<CategoryData>(); for (integer x = 0; x < categoryNodeList.size(); x++) { for (integer i = 0; i < solutionIdList.size(); i++) { If (caseFeatureAreaMap.get(solutionCaseMap.get(solutionIdList[i])) == categoryNodeList[x].MasterLabel) { CategoryData cd = new CategoryData(); cd.CategoryNodeId = categoryNodeList[x].id; cd.RelatedSobjectId = solutionIdList[i]; category.add(cd); } } } insert category; } }

 

 

 

 

ehartyeehartye
figured out my own issue. I just realized that I was reusing some test code from another project and had already created categories for the inserted solutions, hence the duplicates. False alarm!
This was selected as the best answer
heamanheaman

i  got the same error   when   a user chooses  to flip account and flip reason,  this  eerror  messgae pops up,   can  some one expalin whats  this?

MyGodItsColdMyGodItsCold

I just got it inside Spring '13 Developer Console - but it gave an id

 

 

duplicate value found: ScopeId duplicates value on record with id: 1doP00000004CMh

 

It's sporatic and doesn't really hurt anything, but I was wondering what kind of object has ID's beginning with '1do'

 

 

(looks like a marriage vow to me)

AndrewFisher_TGPAndrewFisher_TGP

I am getting a similar message in the Dev Console on Winter'13 - it was occurring intermittently when saving - but in the last few saves, it won't let me know and keeps popping up:

 

duplicate value found: ScopeId duplicates value on record with id: 1doR0000000xxxx
 
I am very curious as to what the 1do ID refers to...
priyanka_sfpriyanka_sf

Hi, can you please give me more detailed expalination for the issue...

I m getting this error in my code...

when exactly does this problem occur?

Its urgent.....

your help would be great

AndrewFisher_TGPAndrewFisher_TGP

Issue for me appears when pressing save in the developer console - it appears to happen when it is saved, close to the trigger/class being run/activated... So my hunch at to the message popping up due to duplicate salesforce processes using the same ID, for example:

 1x process was for class/trigger running (ie running a test class)

 1x process was to save the class, though the ID 

 

As I said this is only a hunch, it doesn't seem to actually impact anything significantly - if I get the pop-up message, I just ensure the * next to the class/trigger name has disappeared (as this confirms the save process completed).

Thomas DvornikThomas Dvornik

Hey Guys,

 

The prefix '1do' refers to a ApexExecutionOverlayAction. If you're using the developer console, this is what we refer to as a heap dump. 

 

That message will come up if it is trying to set a heap dump on the same class + line, as that is unique. Since you all are seeing it when you save a class, it is most likely a bug in the developer console when it is refreshing the heap dump markers without clearing them properly.

 

i.e. Set a heap dump marker in the gutter, and save the class. I beleive this is is fixed in the next release.

 

Cheers

Baird_SBaird_S

Just ran into this while deploying to a very old instance.  I was getting:

 

File Name: objects/Opportunity.object
Full Name: Opportunity.StageName
Action: NO ACTION
Result: FAILED
Problem: duplicate value found: <unknown> duplicates value on record with id: <unknown>

 

The duplicate that was causing the error was a stageName value which was Inactive in the target instance, and active in the source.  I deleted the inactive target value, and the deployment worked.