You need to sign in to do that
Don't have an account?

Accessing User Info from Apex
I created a custom field called theme__c in the User Object.
I created a custom object called Theme__c with fields listing the colors for various parts of my VF page.
I created a VF page using a custom apex controller and used fields from the Theme__c Object to fill in the CSS color values.
My problem now lies in accessing the custom field theme__c in the User Object in order to retrieve the color fields in the theme__c Object.
Here is what I tried:
public theme__c getTheme(){
string usertheme = User.theme__c;
theme__c theme = [select bg_color__c, primary_color__c, accent_color__c from theme__c where name = :usertheme];
return theme;
}
I get an error because User.theme__c is of a datatype SObject field and I am trying to cast it as a string.
What up with that?
Message Edited by Jim Boudreaux on 12-05-2008 06:54 AM
I created a custom object called Theme__c with fields listing the colors for various parts of my VF page.
I created a VF page using a custom apex controller and used fields from the Theme__c Object to fill in the CSS color values.
My problem now lies in accessing the custom field theme__c in the User Object in order to retrieve the color fields in the theme__c Object.
Here is what I tried:
public theme__c getTheme(){
string usertheme = User.theme__c;
theme__c theme = [select bg_color__c, primary_color__c, accent_color__c from theme__c where name = :usertheme];
return theme;
}
I get an error because User.theme__c is of a datatype SObject field and I am trying to cast it as a string.
What up with that?
Message Edited by Jim Boudreaux on 12-05-2008 06:54 AM
All Answers