You need to sign in to do that
Don't have an account?
jboardman
Change wherestr to allow an OR
I need a little help making a slight change to an apex class.
Current code:
if (UnitType == 'New Unit')
wherestr += 'And Family != \'Refurbished\' ';
else if (UnitType == 'Refurbished Unit')
wherestr += 'And Family = \'Refurbished\' ';
Need it to have an OR statement to exclude or include (respectively) a second product family of Spare Parts like whats below, but that isn't correct and is where I need help.
if (UnitType == 'New Unit')
wherestr += 'And Family != \'Refurbished\' OR \'Spare Parts\' ';
else if (UnitType == 'Refurbished Unit')
wherestr += 'And Family = \'Refurbished\' OR \'Spare Parts\' ';
Current code:
if (UnitType == 'New Unit')
wherestr += 'And Family != \'Refurbished\' ';
else if (UnitType == 'Refurbished Unit')
wherestr += 'And Family = \'Refurbished\' ';
Need it to have an OR statement to exclude or include (respectively) a second product family of Spare Parts like whats below, but that isn't correct and is where I need help.
if (UnitType == 'New Unit')
wherestr += 'And Family != \'Refurbished\' OR \'Spare Parts\' ';
else if (UnitType == 'Refurbished Unit')
wherestr += 'And Family = \'Refurbished\' OR \'Spare Parts\' ';
'AND (Family != \'Refurbished\' OR Family != \'Spare Parts\') '
will include all records because if it's "Refurbished", then it's not "Spare Parts" and vice versa. It should be:
'AND (Family != \'Refurbished\' AND Family != \'Spare Parts\') '
Glyn Anderson
Sr Developer | System Analyst | ClosedWon | closedwon.com
Certified Developer | Certified Advanced Administrator
Blog: GlynATheApexGuy@blogspot.com
Twitter: @GlynAtClosedWon
All Answers
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\') ';
'AND (Family != \'Refurbished\' OR Family != \'Spare Parts\') '
will include all records because if it's "Refurbished", then it's not "Spare Parts" and vice versa. It should be:
'AND (Family != \'Refurbished\' AND Family != \'Spare Parts\') '
Glyn Anderson
Sr Developer | System Analyst | ClosedWon | closedwon.com
Certified Developer | Certified Advanced Administrator
Blog: GlynATheApexGuy@blogspot.com
Twitter: @GlynAtClosedWon
-Glyn