You need to sign in to do that
Don't have an account?

E-mail Service to Create Contact
I'm having some difficulties creating an e-mail service that creates Contacts, which can then be linked to an Opportunity using OpportunityContactRole. I'm not getting e-mail error logs when I send my tests, so I can't figure out what's going wrong. Here's the key bit of the code that I think is not working properly:
if(!event_code.equals('')) { Opportunity opp = [Select ID From Opportunity Where Event_Code__c = :event_code limit 1]; Contact primaryContact = new Contact(); primaryContact.LastName = event_last; primaryContact.FirstName = event_first; try{ insert primaryContact; }catch(DMLException e){ system.debug('ERROR Inserting attachment:'+e.getDMLMessage(0)); } OpportunityContactRole primaryContactRole = new OpportunityContactRole(); primaryContactRole.ContactId = primaryContact.id; primaryContactRole.OpportunityId = opp.id; try{ insert primaryContactRole; }catch(DMLException e){ system.debug('ERROR Inserting attachment:'+e.getDMLMessage(0)); } }
Try adding this to your new Opp Contact Role area:
Also, you're inserting a contact without an accountId.
That sounds like the two places that's wrong.
But you can also set the debug log for the user who is set to process these records - when the service is called it will show you the errors...