INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds

Introduction This error is thrown while sending email using apex if you are setting User Id in target recipient: setTargetObjectId(usr.Id) and also specifying target record id as: setWhatId(opp.Id). As per Salesforce documentation if you are passing record id in WhatId then you can only pass Contact Id in setTargetObjectId. Here is Salesforce article: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm Workaround

Salesforce Diagramming Framework

Diagrams help drive key project decisions, align delivery teams, and help everyone understand where you’re going and what’s been done. Consistent, easy-to-understand diagrams are a critical part of project success. But there hasn’t been guidance from Salesforce on how to build great diagrams until now. 3 CONSIDERATIONS WHEN BUILDING SALESFORCE DIAGRAMS 1. You are managing …

Salesforce Diagramming Framework Read More »