• BP Murthy
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi I'm new to Salesforce
In the follwing code, how can I avoid using the con List.
Is there a way in which you can use SOQL query on trigger.new directly instead of bringing in another List ??
trigger ContactTest on Contact (before insert, before update) {

    List<Contact> con = [Select Id, Account.Phone from Contact where Id in : trigger.new];
    for(Contact c: trigger.new)
    {

         for(Integer i=0; i< trigger.new.size() ; i++)
    {
        c.OtherPhone = con[i].Account.Phone;
    }
}

}

Also, can the above update be done with WOrkflow Rules ??

Thanks,
Murthy