Using Userinfo.getSessionId in LWC Throws Invalid Session Id

PROBLEM After Summer ’17, Salesforce disabled it while using in Lightning Domain to enforce the security measures. Here is Salesforce known issue: https://issues.salesforce.com/issue/a028c00000qQ1F3AAK/summer17–generating-a-session-id-from-lightning-domain-provides-invalid-session-id Solution – Named Credential Use Named Credential to get the session id. Steps: Once you’ve logged in there, the refresh token is saved and used by the named credential. From there, you …

Using Userinfo.getSessionId in LWC Throws Invalid Session Id Read More »

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