Skip to main content
I need a little help making a slight change to an apex class.

 

We recently had to move a few products into different product families, and now I need to change this snip of code from:

 

if (UnitType == 'New Unit')

 

wherestr += 'And Family != \'Refurbished\' ';

 

else if (UnitType == 'Refurbished Unit')

 

wherestr += 'And Family = \'Refurbished\' ';

 

to something with and OR statement to exclude or include (respectively) a second product family of Spare Parts.

 

if (UnitType == 'New Unit')

 

wherestr += 'And Family != \'Refurbished\' OR \'Spare Parts\' ';

 

else if (UnitType == 'Refurbished Unit')

 

wherestr += 'And Family = \'Refurbished\' OR \'Spare Parts\' ';
11 answers
  1. Jan 15, 2014, 6:29 PM
    Gotcha!

     

    Try this:

     

    if (UnitType == 'New Unit')

     

        wherestr += 'AND (Family != \'Refurbished\' OR Family != \'Spare Parts\') ';

     

    else if (UnitType == 'Refurbished Unit')

     

        wherestr += 'AND (Family = \'Refurbished\' OR Family = \'Spare Parts\') ';
0/9000