You need to sign in to do that
Don't have an account?
Vincent.Ip
Upsert Error "Duplicate id in list: false"
This is more of an FYI, as i did seem to find any where else this was posted. Hopefully this saves someone from a headache.
I was getting an error message "Duplicate id in list: false" from the following statements. The exception itself was from the upsert statement.
List<Chat_Transcript__c> allTranscripts;
...
for ( ... ){
Chat_Transcript__c currChat = new Chat_Transcript__c();
....
allTranscripts.add(currChat);
}
...
upsert allTranscripts Chat_Number__c;
Don't know if anyone else was having this problem, but hopefully this fix helps you.
I was getting an error message "Duplicate id in list: false" from the following statements. The exception itself was from the upsert statement.
List<Chat_Transcript__c> allTranscripts;
...
for ( ... ){
Chat_Transcript__c currChat = new Chat_Transcript__c();
....
allTranscripts.add(currChat);
}
...
upsert allTranscripts Chat_Number__c;
The records in the allTranscripts had an externalId put into the Chat_Number__c field and all Chat_Transcript__c records in the list were created programmatically with a new Chat_Transcript() statement. I double checked to make sure that the records within the list did not have duplicate Chat_Number__c values.
Not sure when this bug seemed to show up, but upserting like this caused the error message to appear. I fixed this by adding the following to the code.
Not sure when this bug seemed to show up, but upserting like this caused the error message to appear. I fixed this by adding the following to the code.
List<Chat_Transcript__c> allTranscripts;
...
for ( ... ){
Chat_Transcript__c currChat = new Chat_Transcript__c();
currChat.Id = null;
....
allTranscripts.add(currChat);
}
...
upsert allTranscripts Chat_Number__c;
...
for ( ... ){
Chat_Transcript__c currChat = new Chat_Transcript__c();
currChat.Id = null;
....
allTranscripts.add(currChat);
}
...
upsert allTranscripts Chat_Number__c;
Don't know if anyone else was having this problem, but hopefully this fix helps you.
allTranscriptsSet.addAll(allTranscripts); // Eleminating duplicates
allTranscripts.clear();
allTranscripts.addAll(allTranscriptsSet);// Put it back
upsert allTranscripts; // Upsert the deduplicate records