You need to sign in to do that
Don't have an account?
Dan Dodd 3
email to case stopped working with before insert trigger
I have email-to-case working great until I add a trigger to the process and then email-to-case stops working.
I have commnted out most everything and it still fails to run. here is what I need to run:
I have commnted out most everything and it still fails to run. here is what I need to run:
trigger CaseInsertTrigger on Case(before insert, after insert){ if (Trigger.isBefore && Trigger.isInsert) { Set<String> conEmailSet = new Set<String> (); String userEmail; for(case cs: Trigger.new){ if(cs.contactid == null) { if (cs.description !=null && cs.subject.mid(0, 12) == 'Issue Report') { userEmail = cs.description.substringBetween('Email: ',' EndEmail'); if ( userEmail != null) { conEmailSet.add(userEmail); system.debug(userEmail); } } } } Map<String, Contact> cEmailMap = new Map<String, Contact>(); for(Contact eMap : [select Email, Id from contact where Email IN :conEmailSet]) { cEmailMap.put(eMap.Email,eMap ); } Contact tmpContact; for(case cs: Trigger.new){ if(cs.description !=null && cs.subject.contains('Issue Report') ) { userEmail = cs.description.substringBetween('Email: ',' EndEmail').trim(); system.debug('Queue for Case:--->' + cs.OwnerId); system.debug('Email for case: ' + userEmail); if ( userEmail != null) { tmpContact = cEmailMap.get(userEmail); if ( tmpContact != null ) { cs.ContactId = tmpContact.Id; system.debug('Contact for Case:--->' + tmpContact.Id); } else { //here ToDo crreate a contact } cs.SuppliedEmail = userEmail; // ToDo OwnerId ie Queue app queue , why does ? // ToDo cs.SuppliedName } else { system.debug('Contact for Case:--->None '); } } } } }
Added this trigger in my local org. I see the case getting created using Email-to-case (None of the debug statements in the code were displayed though. May be the critieria was not met?)
Are you seeing any exception at your end? Thanks
Anudeep
All Answers
Added this trigger in my local org. I see the case getting created using Email-to-case (None of the debug statements in the code were displayed though. May be the critieria was not met?)
Are you seeing any exception at your end? Thanks
Anudeep
No exceptions on my end, I don't see the case..
I'll look in Classic. We don't use it.
Thank you
Dan
Thanks