Hot answers tagged


Don't Skimp on Curly Brackets You may think that you're saving some space/typing with: if (em.Incoming) caseIds.add(em.parentId); But you're actually risking a very subtle bug. Commenting a line or adding a new line might not be codified in the if statement correctly, leading to unexpected logic errors or compilation errors. It's not worth it. Don't ...


In your test class, you are trying to query a case record where you look up against a contact Id, that will never yield a result. Instead: List<Case> cs = [SELECT Id, ContactId, AccountId FROM Case WHERE Id = :cont.Id]; Change it to: List<Case> cs = [SELECT Id, ContactId, AccountId FROM Case WHERE ContactId = :cont.Id];


That's just an artifact of using the developer console. If you use anonymous apex to run that query, and system.debug(myEmailMessage.Parent.RecordType.Name); (system.debug doesn't print nested objects, or does so very minimally) or system.debug(JSON.serialize(myEmailMessage));, you'll see that you do in fact get the data you requested in your query.


The Lightning Flows would help in this scenario. You can set up a series of screens with decision points and even automate actions off the back of those responses. Even better, with Einstein "Next Best Action" you can recommend a script based on what the customer is saying.

Only top voted, non community-wiki answers of a minimum length are eligible