1

I want to lookup the current SupportTier field in Account object according to the user that is logged in and pass it to the VF page. For some reason it is not working correctly. Getting a "Variable not exist" error.

Controller >>>>>>>>>>>>>>>>>

    public String GetSupportTierValue {
  get {
    if( GetSupportTierValue == null ) {
       String SupportTier = [SELECT Id, Name, Support_Tier__c
                       FROM Account
                       WHERE Id IN 
                            (SELECT AccountId 
                               FROM user 
                              WHERE username=:UserInfo.getUsername()
                             )
                       LIMIT 1
                     ].Support_Tier__c;

       SupportTierValue = SupportTier;
    }
    return SupportTierValue;
  }
  set { SupportTierValue = SupportTier; }

}

VisualForce Page >>>>>>>>>>>>>>>>>

var GetSupportTierValue = '{!GetSupportTierValue}';
0

If you are using getter/setter then do not specify get in the attribute name.

You can change it like this way:

public String SupportTierValue {
  get {
    if( SupportTierValue == null ) {
       String SupportTier = [SELECT Id, Name, Support_Tier__c
                       FROM Account
                       WHERE Id IN 
                            (SELECT AccountId 
                               FROM user 
                              WHERE username=:UserInfo.getUsername()
                             )
                       LIMIT 1
                     ].Support_Tier__c;

       SupportTierValue = SupportTier;
    }
    return SupportTierValue;
  }
  set {}

}

visualforce:

var GetSupportTierValue = '{!SupportTierValue}';

For more information, refer Apex Properties

2
  • Thank you Santanu, I did just like you said. Now I am getting this error: "Compile Error: Variable does not exist: SupportTier" - its in the Set { line
    – ObiDarrell
    Jan 13 '17 at 16:52
  • dont set anything in Set Jan 13 '17 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.