• Salluri Leelavathi
  • NEWBIE
  • 25 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I tried this code but not working. Can any one help me on this?

trigger Contactduplicaterecord on Contact (before insert, before update) 
{
  set<string> EmaPho=new set<string>();
    
    for(Contact Con:trigger.new)
    {
        EmaPho.add(Con.Phone);
        EmaPho.add(Con.Email);
     }
    if(EmaPho.size()>0 )
    {
    List<Contact> lstContact=[Select Phone,Email from Contact where Phone in:EmaPho or Email in:EmaPho];
    Map<string, Contact> MapEmaPhowisecontact=new Map<string, Contact>();
    
    for(Contact Con:lstContact)
    {
        MapEmaPhowisecontact.put(Con.Phone, Con);
        MapEmaPhowisecontact.put(Con.Email, Con);
    }
    for(Contact Con:trigger.new)
    {
        if(MapEmaPhowisecontact.containsKey(Con.Phone))
        {
            Con.Phone.addError('Phone Number already Exist');
        }
        if(MapEmaPhowisecontact.containsKey(Con.Email))
        {
            Con.Email.addError('Email already Exist');
        }
    }
    }
}
Hi, can any one help me with trigger on Account , when an account insert , automatically account billing address should populate into the account shipping address.

I wrote this but not working
trigger AddressUpdate on Account (before insert) 
{
  for(Account Acc:trigger.new)
  {
      Acc.BillingStreet=Acc.ShippingStreet;
      Acc.BillingCity=Acc.ShippingCity;
      Acc.BillingCountry=Acc.ShippingCountry;
      Acc.BillingState=Acc.ShippingState;
      Acc.BillingPostalCode=Acc.ShippingPostalCode;
  }
}
I tried this code but not working. Can any one help me on this?

trigger Contactduplicaterecord on Contact (before insert, before update) 
{
  set<string> EmaPho=new set<string>();
    
    for(Contact Con:trigger.new)
    {
        EmaPho.add(Con.Phone);
        EmaPho.add(Con.Email);
     }
    if(EmaPho.size()>0 )
    {
    List<Contact> lstContact=[Select Phone,Email from Contact where Phone in:EmaPho or Email in:EmaPho];
    Map<string, Contact> MapEmaPhowisecontact=new Map<string, Contact>();
    
    for(Contact Con:lstContact)
    {
        MapEmaPhowisecontact.put(Con.Phone, Con);
        MapEmaPhowisecontact.put(Con.Email, Con);
    }
    for(Contact Con:trigger.new)
    {
        if(MapEmaPhowisecontact.containsKey(Con.Phone))
        {
            Con.Phone.addError('Phone Number already Exist');
        }
        if(MapEmaPhowisecontact.containsKey(Con.Email))
        {
            Con.Email.addError('Email already Exist');
        }
    }
    }
}