+ Start a Discussion

trigger, email new lead

Ok, I'm just getting started in SF, and I'm under a time crunch.  Normally for a basic problem like this I would spend the time to RTFM before asking this, but right now I just need help getting this done.


We have leads that are coming in two ways, entered directly into SF, and by filling out a form on our website.  I want to create an insert trigger that sends a welcome email IF the 'send_welcome_email' flag is set on the user.  Then I want to clear the flag.


So far, I have nothing.  The only thing I DO have is the force IDE set up so I can put triggers on my leads (I'm not working on the sandbox, but the real thing.)  I've done a blank trigger just to make sure, and it is installing.


Does anyone have an example of what this trigger should look like? 



Not that it matters, but my experience is in PHP. 

Best Answer chosen by Admin (Salesforce Developers) 

All Answers

This was selected as the best answer

Thank you!


I also realized I could use workflow to look at the Welcome_email field I just created, send an email, then clear the field.

And I've already got PHP creating leads in the system with Welcome_email__c = True, which also sends.


Oh, and I made my workflow create a follow up task as well.

So, when would you suggest I use APEX to do a trigger vs creating a workflow?  I guess APEX is more flexible and would do whatever you asked of it.


You did the right thing. We always recommend using the core declarative features instead of Apex when it can do what you need.