You need to sign in to do that
Don't have an account?
Benjamin Oliver
Simple Trigger Question - Value Updates Optional Checkbox Field
Hi Community,
I need a trigger to check a Lead's zip code and determine if it matches a set of zip codes that my business services. If it is a matching zip code, I would like Salesforce to update a checkbox field called 'Local Delivery'. This way we can identify which Leads are close to our business. I believe the pseudo code looks like:
trigger UpdateLocalDelivery on Lead (before insert) {
for (Lead lead : trigger.new){
// if Lead.zip equals one of the following zip codes [22202, 22203, 22204, 22201]
// then set Lead.Local_Deliver__c = true;
}
Thank you in advance!
Also, what would the unit test for this trigger look like?
I need a trigger to check a Lead's zip code and determine if it matches a set of zip codes that my business services. If it is a matching zip code, I would like Salesforce to update a checkbox field called 'Local Delivery'. This way we can identify which Leads are close to our business. I believe the pseudo code looks like:
trigger UpdateLocalDelivery on Lead (before insert) {
for (Lead lead : trigger.new){
// if Lead.zip equals one of the following zip codes [22202, 22203, 22204, 22201]
// then set Lead.Local_Deliver__c = true;
}
Thank you in advance!
Also, what would the unit test for this trigger look like?
You could test the trigger in a unit test like this:
I'd also test that inserting a lead with a zip not serviced results in a Local_Delivery__c of false. Hope this helps!
Here is a link to read up on custom settings if you aren't already familiar: https://help.salesforce.com/apex/HTViewHelpDoc?id=cs_about.htm