Plugin Create Record from Track Email ISV Error RRS feed

  • Question

  • Is there a way to check if contact exists in CRM and if not ignore them? I am running into an error where if the to or from contact in the email doesn't exist in the CRM it throws a ISV error. I need to check if the to or from value equals a specific user if it does it creates a lead if not it does nothing. The only way I know to check the to or from fields is to create the activityparty array and then check those values but if they don't even exist in the first place in the CRM it throws that ISV error. Is there code that can check if they exist in the CRM before trying to grab the contact values out of the CRM contact records?

    Below is the bit of code I have that checks who the to and from persons are. The to catch prevents the ISV error if the from person doesn't exist in the CRM when tracking. However, now people are going back and tracking sent emails and that throws off the "to" catch and then gives the ISV error. So I'm hoping there is a simply way to just say if the contact doesn't exist in the CRM don't run the plugin.

    Thanks for any help!

    EntityCollection emailTo = entity.Attributes["to"] as EntityCollection;
                        EntityReference toEmail = emailTo[0].Attributes["partyid"] as EntityReference;
                        Guid emailToId = toEmail.Id;
                        Guid myId = new Guid("E200F73B-57CC-E111-B35F-12A32B1E376A");
                    if (emailToId == myId)
                        EntityCollection emailAddress = entity.Attributes["from"] as EntityCollection;
                        EntityReference email = emailAddress[0].Attributes["partyid"] as EntityReference;
                        Guid emailId = email.Id;
                        Guid contactId = new Guid("84B80350-B14B-E311-876F-12A32B1E376A");
                        if (contactId == emailId)

    Friday, November 15, 2013 8:40 PM