• Ravi@2018
  • NEWBIE
  • -16 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I am trying to move opportunity related lsit from duplicate account to other account when a record is update with duplicate Account Name.Here i.e I have two records A and B so when i update name of Account "B" as "A" all opportunity relatedlist data should be moved from Old record A to newly updated record.
Here is my trigger everything look good but trigger is not working can anyone help me find the issue...

trigger MerageAccOpp on Account (after update) {

    if (trigger.isUpdate){
    
        List<Account> lst_acc;
        List<Opportunity> lst_opp;
        String nameaccount;
        Account a;
        for (Account accnew : Trigger.new){
            system.debug('Enetered');
            a=accnew;
         system.debug(a);

        }    
    
        nameaccount=a.Name;
// Here getting the duplicate account into list based on account name
        lst_acc=[select id,name from Account where name=:nameaccount and id!=:a.Id];
        system.debug(lst_acc);
        for(Integer i=0;i<=lst_acc.size()-1;i++){
// Condition to send duplicate account into "i"
            if(lst_acc[i].Id !=a.Id){
                system.debug('continue');
                system.debug(lst_acc[i].name);
                system.debug(lst_acc[i].Id);

//Getting opportunity of duplicate account into lst_opp based on duplicate account Id
     lst_opp=[select id,accountid from opportunity where AccountId=:lst_acc[i].Id];  
                system.debug(lst_opp);       
        
        if(lst_opp!= null){   
         system.debug('Enetered Opp Loop');
            for(Integer j=0;j<lst_opp.size();j++){
              lst_opp[j].AccountId=a.Id;  
                system.debug('AccountId changed');
                   update lst_opp[j];
                system.debug( lst_opp[j].AccountId); 
            }
         }   
         } 
        }                                            
    }
}
}
 
I am trying to move opportunity related lsit from duplicate account to other account when a record is update with duplicate Account Name.Here i.e I have two records A and B so when i update name of Account "B" as "A" all opportunity relatedlist data should be moved from Old record A to newly updated record.
Here is my trigger everything look good but trigger is not working can anyone help me find the issue...

trigger MerageAccOpp on Account (after update) {

    if (trigger.isUpdate){
    
        List<Account> lst_acc;
        List<Opportunity> lst_opp;
        String nameaccount;
        Account a;
        for (Account accnew : Trigger.new){
            system.debug('Enetered');
            a=accnew;
         system.debug(a);

        }    
    
        nameaccount=a.Name;
// Here getting the duplicate account into list based on account name
        lst_acc=[select id,name from Account where name=:nameaccount and id!=:a.Id];
        system.debug(lst_acc);
        for(Integer i=0;i<=lst_acc.size()-1;i++){
// Condition to send duplicate account into "i"
            if(lst_acc[i].Id !=a.Id){
                system.debug('continue');
                system.debug(lst_acc[i].name);
                system.debug(lst_acc[i].Id);

//Getting opportunity of duplicate account into lst_opp based on duplicate account Id
     lst_opp=[select id,accountid from opportunity where AccountId=:lst_acc[i].Id];  
                system.debug(lst_opp);       
        
        if(lst_opp!= null){   
         system.debug('Enetered Opp Loop');
            for(Integer j=0;j<lst_opp.size();j++){
              lst_opp[j].AccountId=a.Id;  
                system.debug('AccountId changed');
                   update lst_opp[j];
                system.debug( lst_opp[j].AccountId); 
            }
         }   
         } 
        }                                            
    }
}
}
 
Hi everyone:

I'd like to study to the Salesforce Certified Platform Developer I exam, and it would be really helpful if you could tell me what are the best resources I can study from to pass the exam, besides the ones that are recommended in the study guide.

Regards,

Angel
Hi All

I am planning to appear for Salesforce Certified Platform Developer I. Not really getting any sample questions or mock questions online.

Appreciate if anybody has any pointers to that!

Thanks In Advance
Priya