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
Angela Skenderi 2Angela Skenderi 2 

Comparison arguments must be compatible types: Decimal, Boolean is the error that I have been receiving. What is the solution?

  private Decimal getCarAllowances() {
    Decimal value = 0;

    for (Pay_Element__c payElement : payElements) {
      if (payElement.Is_Addition__c == true &&
      (payElement.Car_Allowance__c == true))  {
        value += payElement.Value__c;
      }
    }

    return value;
  }
AshwiniAshwini (Salesforce Developers) 
Hi Angela,
The error occurs because you're trying to compare a Boolean field (payElement.Car_Allowance__c) with the true Boolean value directly.

To fix the error, you can simplify the code by removing the == true checks in your if statement like below:
if (payElement.Is_Addition__c && payElement.Car_Allowance__c) {
    value += payElement.Value__c;
}

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