• staylor
  • NEWBIE
  • 0 Points
  • Member since 2007

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

I'm very new at working with Apex code.  Can someone please help me create a test class for the following Apex trigger?

 

1
2
3
4
5
6
7
8
9
10
11
12
13
trigger LeadFixPhoneFormat on Lead (before insert, before update) {
for (Lead i : Trigger.new) {
// Fix Phone Number issues
if (i.Phone != NULL) {
if (i.Phone.startsWith('+1')) {
i.Phone = i.Phone.substring(3);
i.Phone = i.Phone.replace('.', '-');
i.Phone = i.Phone.replaceFirst('(^[0-9][0-9][0-9]).','($1) ');
}
i.Phone = i.Phone.replace('.', '-');
}
    }
}

 

Thank you in advance!

i have a trigger on a lead that throwing errors due to validation rules.  Is there a good way around this?  It is painful trying to skirt the validation rules when a trigger fires?

Hi, Is there any way to convert many leads to accounts / opportunities at once using the Excel Connector?  Is there another appexchange product that does this?
Thanks,
Brian