• gayatri sfdc
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 11
    Replies
Hi,
I want to copy all accounts record in custom object. How can we copy all record in the custom object. Please provide apex class code.

Thanks
How to get notification or email alerts when I modified or Updated records in salesforce Opportunity.where i can write rule or validation..plz reply.
trigger Practise2 on Student__c (after insert,After update) 
{
  Set<id> ids=new set<id>();
  for(Student__c stud1:trigger.new)  
  {
    ids.add(stud1.id);
  }
  
  list<Student__c> stud2=[select id,name,Status_from_Parent__c,College__r.id,College__r.Status__c from Student__c where id in:ids];
  list<College__c> lst=new list<College__c>();
  for (Student__c std3:stud2)
  {
   for(list<College__C> clg:std3.College__r)
   {
    clg.Status__c=std3.Status_from_Parent__c;
    lst.add(clg);
   }
  
  }
  update lst;
  
  }

Greetings

Recently, I had to review a trigger that was made to avoid the overlapping of time when a new event is created. That trigger is not working (still is possible to do overlapping) I cant understand what is happening with that trigger. Please if anybody can help me with I will be grateful. The triiger is the following (was designed for the Event Object):

 

trigger DateCheckerTrigger on Event (before insert) {

    for ( Event  J : Trigger.New ) {

        List<Event> eventList = [select id from event where ActivityDate= :J.ActivityDate and StartDateTime< :J.StartDateTime and EndDateTime> :J.StartDateTime and WhoId= :J.WhoId];
        
        if(eventList.size()>0){
            J.adderror('Ya existe una visita programada a la misma hora');
        }
    }
}


Thanks for your attention.

Best Regards

How to create the Attachments through triggers? please explain with proper scenario! 
Dear All,
I'm getting the following error while invoking SendEmail method :
16:00:18:192 VARIABLE_ASSIGNMENT [11]|e|"common.apex.methods.MessagingStaticMethods$EmailExecutionException: SendEmail failed. First exception on row 15; first error: INVALID_EMAIL_ADDRESS, Invalid to address : null: []"|0x989add4
Appreciate, if you could provide an early resolution of this problem.

Please find the code appended herewith
global class SendReminderForTaskCompletion implements Schedulable {
    
    global void execute(SchedulableContext ctx) {
      
       try{
            List<Task>  lstTask = [Select Id,Subject,Priority,Status,ActivityDate,Description,OwnerId, TAT__c from Task where Status != 'Completed' ];                 
                                                         
            sendEmailToTaskOwner(lstTask); 
           
       }catch(Exception e)
       {
         System.debug('Error : SendReminderForTaskCompletion->'+ e.getStackTraceString());  
       }
         
   }  
    
    // This method will send Email To Manager automatically
    public void sendEmailToTaskOwner(List<Task> lstTask ){
                
        List<Messaging.SingleEmailMessage> lstMail = new List<Messaging.SingleEmailMessage>();
        
        List<String> ownerId = new List<String>();
        for(Task Tsk: lstTask){
            ownerId.add(Tsk.OwnerId);
        }
       
        List<User> userDetails = [select Id, Name, Email, ManagerId, Manager.Name, Manager.Email from User where Id IN :ownerId];       
                
        List<String> ownerDtlsArray = new List<String>();
        for(User u:userDetails){
            ownerDtlsArray.add(u.Id );
            ownerDtlsArray.add(u.Name );
            ownerDtlsArray.add(u.Email );
            ownerDtlsArray.add(u.ManagerId );
            ownerDtlsArray.add(u.Manager.Name );
            ownerDtlsArray.add(u.Manager.Email );
        }
                      
                    
        
        for(Integer i=0; i< lstTask.size(); i++ ){
            
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();            
            String opprOwnerEmail='';
            String opprOwnerName='';
            String opprOwnerManagerEmail='';
            String opprOwnerManagerName='';
            for(Integer j=0; j< ownerDtlsArray.size(); j=j+6){
             
                if( (lstTask[i].OwnerId).equals(ownerDtlsArray[j]) ){
                    opprOwnerName = ownerDtlsArray[j+1];
                    opprOwnerEmail = ownerDtlsArray[j+2];
                    opprOwnerManagerName = ownerDtlsArray[j+4];
                    opprOwnerManagerEmail = ownerDtlsArray[j+5];
                    break;
                }
            }
             
            String[] toAddresses = new String[] {opprOwnerEmail};
            String[] ccAddresses = new String[] {opprOwnerManagerEmail};   
            System.debug('DEBUG :: SendReminderForTaskCompletion:: toAddresses :: ->'+ toAddresses);
            System.debug('DEBUG :: SendReminderForTaskCompletion:: ccAddresses :: ->'+ ccAddresses);
            if( (toAddresses.size() >0 & toAddresses != null) & (ccAddresses.size() >0 & ccAddresses != null) ){
                mail.setToAddresses(toAddresses);
                mail.setCcAddresses(ccAddresses);                              
                mail.setSubject('Your Pending Tasks ' );
                mail.setHtmlBody('<br/>Due Date of the task <b> :' +lstTask[i].ActivityDate+'</b><br/>'+'Priority of the task : <b>' + lstTask[i].Priority + '</b><br/> Subject : <b>' +  lstTask[i].Subject  + '</b>'+'</b><br/> Description : <b>' +  lstTask[i].Description +'</b>'+'</b><br/> Status : <b>' +  lstTask[i].Status  + '</b>'+'</b><br/> TAT : <b>' +  lstTask[i].TAT__c+' <br/><br/><br/>Thanks & Regards <br/> <br/>Salesforce Administrator');
                //mail.setSaveAsActivity(true); 
                System.debug('DEBUG :: SendReminderForTaskCompletion:: mail :: ->'+ mail);
                lstMail.add(mail);
            }
             
        } 
        System.debug('DEBUG : SendReminderForTaskCompletion:: lstMail :: ->'+ lstMail); 
        if(lstMail.size() >0){
           Messaging.sendEmail(lstMail);   
        }
        
       
    }


}



 

Hi,

 

Is there any way to make LIKE operator work in a case sensitive way in SOQL? Please help.

 

Thanks,

Shashi

Hi,

 

In one of my controller classes I need to retrieve Created By Name field from a custom object.

 

I am running

 

String queryString = 'Select id, File_Name__c, CreatedById, CreatedBy.Name, CreatedDate from ...';

 

Querying the custom object and putting fields in a list:

 

List<SObject> myList = Database.query(queryString);

 

Then trying to set the created by name to a wrapper class field in a loop over myList:

 

w.setCreatedByName((String)f.get('CreatedBy.Name'));

 

But it is giving me

 

Invalid field CreatedBy.Name for XYZ__c

 

What might be the problem. How can I retrieve CreatedBy.Name. I can retrieve CreatedById directly but it is not solving my problem.

 

Thanks...