• julian1.391156003193672E12
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Dear Gurus,

Need your help on the following

[Scenario]
  • Person Account is on the org
  • When changing Account on Case, expected Contact is automatically changed. It was not.
  • I wrote a trigger as follows to enforce changing Contact on Account change.
  • Unfortunately it was not working though there was no error.
[Code]

trigger trgGetContactInfo on Case (before insert, before update, after insert, after update) {

    for(Case cas  : Trigger.New) 
        {    
            //Trigger Action Logic 
            List<Account> accList = [Select id from Account where id =: cas.AccountId]; 
                
            for(Account acc : accList) 
                { 
                    List<Contact> conList = [Select id, name from Contact where id =: acc.id];

                    for(Contact con : conList)
                        {
                            cas.ContactId = con.id;
                        }
                }
      // update cas;
        } 
}

Thanks for your help in advance.
Julian Lee 
Dear Gurus,

Need your help on the following

[Scenario]
  • Person Account is on the org
  • When changing Account on Case, expected Contact is automatically changed. It was not.
  • I wrote a trigger as follows to enforce changing Contact on Account change.
  • Unfortunately it was not working though there was no error.
[Code]

trigger trgGetContactInfo on Case (before insert, before update, after insert, after update) {

    for(Case cas  : Trigger.New) 
        {    
            //Trigger Action Logic 
            List<Account> accList = [Select id from Account where id =: cas.AccountId]; 
                
            for(Account acc : accList) 
                { 
                    List<Contact> conList = [Select id, name from Contact where id =: acc.id];

                    for(Contact con : conList)
                        {
                            cas.ContactId = con.id;
                        }
                }
      // update cas;
        } 
}

Thanks for your help in advance.
Julian Lee