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 

I have 2 different errors regarding my Decimal fields. What would be a good solution?

  private Decimal getCarAllowances() {
    Decimal value = 0;

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

Logical operator can only be applied to Boolean is the error I receive for this method. 

  private Decimal getCarAllowances() {
    Decimal value = 0;

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

Comparison arguments must be compatible types: Boolean, Decimal is the error I receive for this one.

 
Best Answer chosen by Angela Skenderi 2
Arun Kumar 1141Arun Kumar 1141
Hi Angela,

Try below code 
 
private Decimal getCarAllowances() {
    Decimal value = 0;

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

    return value;
}

Please mark it as best answer if it helps

Thanks
 

All Answers

Arun Kumar 1141Arun Kumar 1141
Hi Angela,

Try below code 
 
private Decimal getCarAllowances() {
    Decimal value = 0;

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

    return value;
}

Please mark it as best answer if it helps

Thanks
 
This was selected as the best answer
jenny kim 19jenny kim 19
is it competible for local service website or it should integrate with party involvement.