public class PersonalDashBoardClass {
// attributes come first
public My_Plan__c myPlan;
User currentUser;
String userId;
Integer revenueMax =0;
Integer marginMax = 0;
Integer totalRevenue = 0;
Integer totalMargin = 0;
//Constructor comes next
public PersonalDashBoardClass(ApexPages.StandardController stdController) {
this.myPlan = (My_Plan__c)stdController.getRecord();
currentUser = [Select id from User where id =: UserInfo.getUserId() LIMIT 1];
userId = currentUser.id;
// get the revenue and margin goals from the Goals__C object
try {
Goals__c myGoal = [SELECT Revenue_Goal__C, Margin_Goal__C FROM Goals__c WHERE OwnerId =:UserId AND Start_Date_of_New_Quarter__c = THIS_Quarter LIMIT 1];
Integer revenueMax = (Integer)myGoal.Revenue_Goal__c/1000;
Integer marginMax = (Integer)myGoal.Margin_Goal__c/1000;
System.debug ('the total revenue in the try block is ' + revenueMax);
} catch (exception e) {
system.debug(e);
ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'You must have a goal for the quarter'));
system.debug(' you have an error' +e);
}
// get the total revenue and total margin for closed opportunities for this quarter
try {
AggregateResult ClosedWonOpptys = [select SUM(Amount) totalRevenue, CALENDAR_QUARTER(CloseDate) theMonth, COUNT(Name) numOpps
from Opportunity
where (OwnerId =: UserId OR
Account.Client_Specialist_1__c =:UserId OR
Account.Client_Specialist_2__c =:UserId OR
Account.Client_Executive__c =:UserId)
AND CloseDate = THIS_Quarter
GROUP BY CALENDAR_QUARTER(CloseDate) LIMIT 1];
totalRevenue = Integer.valueOf(closedWonOpptys.get('totalRevenue'))/1000;
} catch (exception e) {
}
system.debug('total revenue = '+totalRevenue + ' and max revenue is ' +revenueMax);
}
public Integer guageChartRevenue {
get {
return totalRevenue;
} set;
}
public Integer guageMaxRevenue {
get {
return revenueMax;
} set;
}
}
Ok, I found the problem. I was reinializing the revenueMax and MarginMax as integer's inside the try block. That gave them local scope, and then after the constructor they went back to zero.Couple hours wasted for a simple mistake, lolThanks,