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
CooldayCoolday 

Only first condition is getting executed in Apex class.

We have a requirement where based on checkbox field different logic should run.

if(fieldname == false || fieldname == true){
//logic
}
else if (fieldname == true){
//logic
}

The issue is only the first condition gets executed.
How can this be resolved.
SwethaSwetha (Salesforce Developers) 
HI,
A checkbox can have only true or false values. Considering that your first condition is an OR condition that is checking both true and false values, it seems quite obvious that the control will not go to the else statement.

Please cross-check if the OR clause is intended here.

If this information helps, please mark the answer as best. Thank you
CooldayCoolday

Hi swetha,

I want to execute both the logics when checkbox is true what can be done in that condition?

Thanks

CooldayCoolday
Got the solution - 

if(fieldname == false || fieldname == true){
//logic
}
if (fieldname == true){
//logic
}