• Spandan
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies

Hi,

 

I'm very  much new to apex and salesforce...has been only few days..Have little knowledge in programming..
kind of stuck writting my first trigger.Please can anyone help..

 

I'm writting a trigger that updates every accounts Account.Master_Score__c ..it searches all its contacts score_card__c field ..gets the max value present and updates..I have made the code very complex...now getting error in last line of code..pls help me completing

error: initial term of field expression must be concrete Sobject : list<id>

 

 

 

trigger trigger_new on Contact (after insert, after update)
{
List<Id> contlist = new List<Id>();
List<Id> contlist1 = new List<Id>();
    List<Id> contlist4 = new List<Id>();
    
Map<Id, Contact>newmap= new Map<Id, Contact>();

     for (Contact c : trigger.new)
    {
     while( c.score_card__c >0 )
   {
        contlist.add(c.id);
        for(contact ca : contlist)
         {
             if(ca.Account.Id=Account.id)
            {
                   contlist1.add(ca.id);
                        List<contact> contlist2=[select id,score_card__c from contact where id in : contlist1];
                        for(contact c2: contlist2)
                      {
                             for(Integer i=0;i<=contlist2.size();i++)
                             {
                                 List<AggregateResult> contlist3=[select MAX(score_card__c) from contact where id in : contlist2];
                                    contlist4.add(c2.id);
                                 c2.Account.Master_Score__c= contlist4.score_card__c;
                                 
                             }
                  
                       }
                  
          
                    
              }
    }
       
   }
     
 }
}

 

 

 

 

 

Hi,

 

I'm very  much new to apex and salesforce...has been only few days..Have little knowledge in programming..
kind of stuck writting my first trigger.Please can anyone help..

 

I'm writting a trigger that updates every accounts Account.Master_Score__c ..it searches all its contacts score_card__c field ..gets the max value present and updates..I have made the code very complex...now getting error in last line of code..pls help me completing

error: initial term of field expression must be concrete Sobject : list<id>

 

 

 

trigger trigger_new on Contact (after insert, after update)
{
List<Id> contlist = new List<Id>();
List<Id> contlist1 = new List<Id>();
    List<Id> contlist4 = new List<Id>();
    
Map<Id, Contact>newmap= new Map<Id, Contact>();

     for (Contact c : trigger.new)
    {
     while( c.score_card__c >0 )
   {
        contlist.add(c.id);
        for(contact ca : contlist)
         {
             if(ca.Account.Id=Account.id)
            {
                   contlist1.add(ca.id);
                        List<contact> contlist2=[select id,score_card__c from contact where id in : contlist1];
                        for(contact c2: contlist2)
                      {
                             for(Integer i=0;i<=contlist2.size();i++)
                             {
                                 List<AggregateResult> contlist3=[select MAX(score_card__c) from contact where id in : contlist2];
                                    contlist4.add(c2.id);
                                 c2.Account.Master_Score__c= contlist4.score_card__c;
                                 
                             }
                  
                       }
                  
          
                    
              }
    }
       
   }
     
 }
}