You need to sign in to do that
Don't have an account?
Accessing class variables
I developed a Chart from a custom salesforce object, but I'm trying in vain to assign a value to a public class variable.
I'm trying to add String data from a LIST<>[Select] output (which works correctly) to a class variable so the TITLE of the chart in the Visualforce page can access it, but I can't seem to SET the value to the public variable.
Obtaining the actual value from the List<>[Select] is easy and works (as tested in Execute Anonymous query}. SETTING the value appears impossible. Is there a special notation when assigning values to variables that are defined by "{ get;set;}?
I have the following:
public class zchartController {
public String RecentDate { get ; set; } // This is where the Controller added the reference.
// I also tried putting the LIST<>[Select] here.
...
public static List<Data> getChartData() {
List<MyObj__c> CurrentDates = [Select OrderDate__C from MyObj__c order by OrderDate__c Limit 1];
// RecentDate = CurrentDates.get(0).OrderDate__c;
...
}
...
}
Nevermind. I figured it out.
I was trying to assign the value in a different subclass. All I had to do was create a simple class constructor that assigned the value.