function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sampath pallisampath palli 

Real time scenarios

Hi

Can any one suggest me project based real time scenario's in development which is on Triggers, SOQL , SOSL , Batch apex, Schedule apex and governing limits

Thanks In Advance
Sampath palli
Amit Chaudhary 8Amit Chaudhary 8
Hi sampath palli,

I will recommend you please try trailhead module for same. IN that you will learn all in a fun a way
1) https://developer.salesforce.com/trailhead/module/database_basics_dotnet
2) https://developer.salesforce.com/trailhead/module/apex_database

Please let us know if this will help you

Thanks
Amit Chaudhary
 
sampath pallisampath palli
Thank u Amit
B SreenivasuluB Sreenivasulu
i have a trigger scenario 
 Create a custom field " Number of Contacts" on Account.  This field should hold the number of contacts are associated to the Account and needs to be get updated at all times. pls help me in this 

Thanks 
Sreeni
Jaya Koti MuleJaya Koti Mule
trigger contactTrigger on Contact (before insert, before Update, before Delete, after insert, after update, after delete, after Undelete) {
    Set<ID> accIdSet = new Set<ID>();
    
    // After Insert 
    if(Trigger.isAfter){   
        if(Trigger.isUndelete || Trigger.isInsert){
            for(Contact c : Trigger.New){
                if(c.AccountId != Null){
                    accIdSet.add(c.AccountID);
                }
            }   
        }
        
        if(Trigger.isDelete){
            for(Contact c : Trigger.Old){
                if(c.AccountId != Null){
                    accIdSet.add(c.AccountID);
                }
            }  
        }
    }
    
    
    List<Account> accList = [SELECT ID, No_of_Contacts__c, (SELECT Id FROM Contacts) FROM Account WHERE Id IN :accIdSet];
    
    if(accList.size() > 0 ){
        for(Account a : accList){           
            a.No_of_Contacts__c = a.contacts.size();
        }
        update accList; 
    }
    
}