Asked by:
An item with the same key has already been added MS CRM 2011

Question
-
Hi All,
I am getting the below exception while adding the meembers to the party lookup in email activity record
"An item with the same key has already been added."
foreach (Guid member in members) {
bccMember.Attributes["partyid"] = new EntityReference("contact", member);//getting the exception in second loop.
}
Thanks
Srikanth Reddy
Wednesday, August 6, 2014 3:29 PM
All replies
-
please post also the rest of the code, this part is not enough to find the issue
My blog: www.crmanswers.net - Rockstar 365 Profile
Wednesday, August 6, 2014 4:25 PM -
Hi Srikanth,
http://msdn.microsoft.com/en-us/library/hh372955.aspx
place the activity party in an array and then assign the array to the bccMember.
Regards,
Jithesh
Thursday, August 7, 2014 12:13 AM -
Hi Thanks for quick response I followed the below link to create email activity in plug-in while adding the contacts(more than one) to the "To" party lookup field, how we can add multiple contacts to the party lookup filed.
http://mileyja.blogspot.in/2012/02/create-email-activity-in-microsoft.html
- Edited by Srikanth_MSCRM Thursday, August 7, 2014 4:45 AM
Thursday, August 7, 2014 3:38 AM -
Party lookup is an activity party entity u can add multiple contacts accounts and add that activity party to tha to field of the email
If my response answered your question, please "mark the response as an answer" and also "vote as helpful". Regards, Hari. www.crm2011byhari.blogspot.com
- Proposed as answer by Hari Narayanan Kumar Tuesday, August 12, 2014 6:45 AM
Sunday, August 10, 2014 9:52 AM -
The most likely cause of your problem is if you either use the same Entity instance in your code to create more than one activityparty, or if you use an Entity instance for an activityparty to create a new activityparty. In either case, the primary key of the activtiyparty (activitypartyid) will not change, and that will produce the error. To prevent this, either create a new Entity instance each time, or remove activtiypartyid attribute, and set the .Id property to Guid.Empty to remove the reference to the existing primary key
Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk
Wednesday, August 13, 2014 10:23 AMModerator