You need to sign in to do that
Don't have an account?

Wild card characters allowed?
In my trigger, I want to check if 'Lead Status' is either 'Closed - Working' or 'Closed - Converted'. If it is, then my custom field is set to true. My following code to check one status works but I don't know how to check for 'Closed - Working' OR 'Closed - Converted'
trigger setApntFlag on Lead (before insert, before update) {for (Lead a : Trigger.new) {
If(a.Status == 'Closed - Converted')
{a.ApmntFlag__c = True;}
else
{a.ApmntFlag__c = False;}
}
}
I wonder if you could use OR in the if statement:
If(a.Status == 'Closed - Converted' || a.Status == 'Closed - Working' )
Cheers,
Hey
You could do this:
This is generally not advised because in future you (or someone else) might be asked to add in another status that also starts with 'Closed' but which requires different logic, either in this trigger or somewhere else in your code that uses similar branching logic. That said it's better to use the @Poorman's approach, but there you should also try to use variable names in your conditions and not hardcoded values, making later maintenance easier.
Wes
Would a Workflow Rule + Field Update accomplish the same goal without the need for Apex?