function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JoeyLenJoeyLen 

multiple options for an IF statement

This is such a Newb question but I cannot for the life of me figure it out.  I have the following IF statement in a trigger on the opportunity record:

If(o.StageName=='Closed Won'&& o.Type=='EMC - Mobius,EMC - Mobius,Evo,MP Upgrade,Sydekick Doc + AIO,Sydekick Med,Sydekick Med + AIO,Slimline w/ Mobius,Slimline + AIO,Slimline w/ Mobius w/ IN,Mobius Retrofit')

It works fine with one option for Type but when I try to do mutliple options it doesn't work.  I have tried separating with, with ; with || and nothing works.  How do I edit this so the trigger will fire if the opportunity is closed won and any of the included types?

Thanks.
Best Answer chosen by JoeyLen
AshlekhAshlekh
Hi 

In your code you are check the value of by == operator which check the excat value instead of one of them,
Use below code:
Set<string> s = new Set<string>();
s.add('EMC - Mobius');
s.add('EMC - Mobius');
s.add('Evo');
s.add('MP Upgrade');
s.add('Sydekick Doc + AIO');
s.add('Sydekick Med');
s.add('Sydekick Med + AIO');
s.add('Slimline w/ Mobius');
s.add('Slimline + AIO');
s.add('Slimline w/ Mobius w/ IN');
s.add('Mobius Retrofit');

If(o.StageName=='Closed Won'&& o.Type!=null && s.contains(o.Type))

All Answers

AshlekhAshlekh
Hi 

In your code you are check the value of by == operator which check the excat value instead of one of them,
Use below code:
Set<string> s = new Set<string>();
s.add('EMC - Mobius');
s.add('EMC - Mobius');
s.add('Evo');
s.add('MP Upgrade');
s.add('Sydekick Doc + AIO');
s.add('Sydekick Med');
s.add('Sydekick Med + AIO');
s.add('Slimline w/ Mobius');
s.add('Slimline + AIO');
s.add('Slimline w/ Mobius w/ IN');
s.add('Mobius Retrofit');

If(o.StageName=='Closed Won'&& o.Type!=null && s.contains(o.Type))

This was selected as the best answer
JoeyLenJoeyLen
D-Horse, Thanks so much. The code worked perfect and I learned something new today. Joey Len Salesforce Administrator www.enovatemedical.com | 888.909.8906 x 225