function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Darrell Waddell 223Darrell Waddell 223 

Error: Compile Error: unexpected token: 'List'

Getting this error:
Error: Compile Error: unexpected token: 'List' at line 44 column 8

public String SupportTierValue {
  get {
           
        List tmpAcct = [SELECT Id, Name, Support_Tier__c
        FROM Account
        WHERE Id IN 
        (SELECT AccountId 
        FROM user 
        WHERE username=:UserInfo.getUsername()
        )
        LIMIT 1
        ];
        if (tmpAcct.size() > 0) {
        String SupportTier = tmpAcct[0].Support_Tier__c;
        }
        else {
        String SupportTier = 'SomeDefaultValue';
        }
        
      
       
    }
    return SupportTierValue;
  }
  private set;

}
Shruti SShruti S
It is because you havent defined the type for the List. Lists are usually initialised and declared as 
List<T> identifier = new List<T>();
where T is the Datatype.

Here is the corrected code - 
public String SupportTierValue {
    get { 
        List<Account> tmpAcct = new List<Account>();

        tmpAcct = [
            SELECT  Id
                    ,Name   
                    ,Support_Tier__c
            FROM    Account
            WHERE   Id IN (
                SELECT  AccountId 
                FROM    user 
                WHERE   username = :UserInfo.getUsername()
            )
            LIMIT 1
        ];

        String SupportTier;
        if ( tmpAcct.size() > 0 ) {
            SupportTier = tmpAcct[0].Support_Tier__c;
        }
        else {
            SupportTier = 'SomeDefaultValue';
        }  

        return SupportTier;
    }
    
    private set;
}
Amit Chaudhary 8Amit Chaudhary 8
Try to set type of list
EX: List<Account> accList = new List<Account>();

Update your code like below
public String SupportTierValue {
  get {
           
        List<Account> tmpAcct = [SELECT Id, Name, Support_Tier__c
									FROM Account
									WHERE Id IN 
									(SELECT AccountId 
										FROM user 
										WHERE username=:UserInfo.getUsername()
									)
									LIMIT 1
									];
        if (tmpAcct.size() > 0) 
		{
			String SupportTier = tmpAcct[0].Support_Tier__c;
        }
        else 
		{
			String SupportTier = 'SomeDefaultValue';
        }
    }
    return SupportTierValue;
  }
  private set;

}

Let us know if this will help you