• Preetika Gupta 8
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I'm trying to make some code that will add up the total value of a select field within a list i have created. I then want to subtract it from a set value. But i just keep getting an error. Can anyone please advise?

public with sharing class Total{

    Private integer allowance=252;
    public integer total_used;
    
    public Total(){
        total_used = [select sum (Hours_Used__c) FROM Holiday_Request__c WHERE Staff_Memeber__r.Name = 'Dan'];
    }
    
    Public Integer gettotal_used() {
        return total_used;
    }
    
    Public Integer getAvailable() {
        return 252-21;
    }
}