
I Can do this with workflow rule but want to try it writing a trigger. Im very new to salesforce :-)
4 réponses
Welcome to the world of force.com
Tip number 1 :
When ever you can do something using Point and click (i.e. workflows, formulas etc..) , go for it and try to avoid coding.
Reason being , code has more chances of failure , constraints of governor limits and also you have to write test classes for each trigger / class you write.
To answer your question
Goto the Object --> on Trigger Section of the object detail --> click new
might look like this
difference between before and after trigger
http://hisrinu.wordpress.com/2011/05/17/difference-between-before-trigger-and-after-trigger/
Trigger mytriggerName on Candate__c (before update,before insert)
{
// Bulkify the code : i.e. expect more than 1 record to come in to trigger at same time
for(Candidate__c c: Trigger.new)
{
if(!c.US_Citizen__c)
c.Visa_Required__c = true;
// Since its before trigger you dont need to update the object that you triggerd
}
}