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

Recalculate Formula Fields Dynamically (without save)

From the Documentation: Recalculates all formula fields on an sObject, and sets updated field values. Rather than inserting or updating objects each time you want to test changes to your formula logic, call this method and inspect your new field values. Then make further logic changes as needed. See https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm Note that this method doesn’t recalculate …

Recalculate Formula Fields Dynamically (without save) Read More »

How to Query External Object in Salesforce?

Introduction Query on external object is supported with some limitation. Here is Salesforce help article: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_limits.htm Sample Query SELECT Id, Name__c, OrderNumber__c FROM ExternalOrder__x WHERE Name__c LIKE ‘%Software%’ Additional Notes

How to add field on Product selection screen in Salesforce

Question How do I customise the columns that appear in the Add Products popup which appears if you click the Add Products button on the Products related list on the Opportunities record page? What you’ve tried so far but it does not work: You might have tried below solution, but it won’t work actually. SOLUTION Follow given steps :