You need to sign in to do that
Don't have an account?
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.
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.
Apex Code Development
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
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