Posts

Developer productivity tools

  1.LWC Short Keys VS Code Extension for  #Salesforce 2. pmd

Formula To Calculate The Number Of Days Between Two Dates While Excluding Weekends

  However it’ll not exclude the HOLIDAYS, Because each org has its own holidays based on region /country. Hence salesforce don’t have knowledge about list of holidays. CASE(MOD( StartDate__c – DATE(1985,6,24),7),    0 , CASE( MOD( EndDate__c – StartDate__c ,7),1,2,2,3,3,4,4,5,5,5,6,5,1),    1 , CASE( MOD( EndDate__c – StartDate__c ,7),1,2,2,3,3,4,4,4,5,4,6,5,1),    2 , CASE( MOD( EndDate__c – StartDate__c ,7),1,2,2,3,3,3,4,3,5,4,6,5,1),    3 , CASE( MOD( EndDate__c – StartDate__c ,7),1,2,2,2,3,2,4,3,5,4,6,5,1),    4 , CASE( MOD( EndDate__c – StartDate__c ,7),1,1,2,1,3,2,4,3,5,4,6,5,1),    5 , CASE( MOD( EndDate__c – StartDate__c ,7),1,0,2,1,3,2,4,3,5,4,6,5,0),    6 , CASE( MOD( EndDate__c – StartDate__c ,7),1,1,2,2,3,3,4,4,5,5,6,5,0),    999)    +    (FLOOR(( EndDate__c – StartDate__c )/7)*5)  Steps to create: Create a formula fi...

rollup summary with bulk record handling without hitting governer limits

 Contact Trigger : ================================================ trigger ContactTrigger on Contact (before insert, after insert, before update, after update, before delete, after undelete, after delete) {       Set<Id> accIds = new Set<Id>();// set to store parent account ids of contacts    map<string,Account> accconmap1=new map<string,Account>();    map<string,string> accconmap=new map<string,string>();    map<string,string> accconmap2=new map<string,string>(); if(trigger.isAfter && (trigger.isInsert || trigger.isUndelete)) { if(!trigger.new.isEmpty()){             Integer i=0; for(Contact con : trigger.new) {                  accIds.add(con.AccountId);                  accconmap.put(con.id,con.AccountId); } } } if(trigger.isAft...

Email Merge Fields missing - resoling

1. Check field-level permissions. 2. if you are sending from apex check, in soql those fields are mentioned. 3. check the template name if you are cloning some templates. 4. check HTML code in template if any conditional display.

get Salesforce base url using apex

  URL.getSalesforceBaseUrl().toExternalForm();

How to delete .invalid In user Email (For selected emails only Or for all users) for newly created sandbox or refreshed sandbox

1. Create this class -------------------------------------------------------------------- public class EmailUtils {     public Static String removeInvalidDomain(String email) {         if (email != null && email.contains('@')) {             String[] parts = email.split('@');             String username = parts[0];             String domain = parts[1].toLowerCase();                          if (domain.endsWith('.invalid')) {                 domain = domain.substring(0, domain.length() - 8);             }                          return username + '@' + domain;         }                  return email; ...

Apex Schedules ,Scheduled Jobs Cron Expressions

Cron Expressions for Subscription Schedules  https://help.salesforce.com/s/articleView?id=sf.reports_subscription_reporting_cron.htm&type=5 Run Scheduled Apex job only once https://help.salesforce.com/s/articleView?id=000382128&type=1