Set<String> roles = AccountRoleCustomSettingsNames.All;
        for (AccountTeamMember member : [SELECT UserId, TeamMemberRole, Id, AccountId FROM AccountTeamMember WHERE AccountId IN :accounts AND TeamMemberRole IN :roles])
            existingMemberMap.put(member.AccountId + member.TeamMemberRole, member);

        for (Account account : accounts) {

 private static void process(Account account) {
            teamRoles = Account_Team_Roles__c.getAll();
            process(account, AccountRoleCustomSettingsNames.SOLUTION_SPECIALIST,            account.Solution_Specialist__c);
            process(account, AccountRoleCustomSettingsNames.STATE_MGR,                      account.State_Mgr__c);
            process(account, AccountRoleCustomSettingsNames.STRATEGIC_ACCOUNT_DIRECTOR,     account.Strategic_Account_Mgr__c);
            process(account, AccountRoleCustomSettingsNames.STRATEGIC_ACCOUNT_SYSTEM_SALES, account.Strategic_Acct_System_Sales__c);
            process(account, AccountRoleCustomSettingsNames.STRATEGIC_ACCT_VP,              account.Strategic_Acct_VP__c);

            if(account.Region__c != 'Asia' && account.Region__c != 'ANZ') 
            process(account, AccountRoleCustomSettingsNames.SYSTEM_AM,                      account.System_AM__c);
            else process(account, AccountRoleCustomSettingsNames.System_AM_APAC,            account.System_AM__c);  

            process(account, AccountRoleCustomSettingsNames.SYSTEM_SALES_DIRECTOR,          account.Systems_Sales_Director__c);

So I went into the custom settings---> a definition that handles team roles and created 'System AM APAC'. Then i went into team roles for accounts and created 'System AM APAC'.

Now all the other AccountRoleCustomSettingsNames. work, it's just the System AM APAC that gives me "Variable does not exist: System AM APAC" error.

Now i should say i've tried AccountRoleCustomSettingsNames.SYSTEM_AM_APAC and System_AM_APAC, neither work. I should note that SYSTEM_AM works fine, but in the custom settings it's listed as System AM (api name as well) so that shouldn't matter....i can seem to figure out whats causing the issue. I know it's a static object, maybe it needs a day?

  • 2
    n.b. you currently have three past open questions, all of which have an answer. Consider accepting any answers that solved your problems - you'll get a small reputation bump, as will the answerer, and the question will be marked as resolved. – David Reed Aug 29 '18 at 19:48

The name implies that AccountRoleCustomSettingsNames is an Apex class, which appears to contain string constants that define the names of Custom Settings records and Team Role names.

In addition to creating your Custom Setting and your Team Member Role, you would need to declare a constant in your AccountRoleCustomSettingsNames class like SYSTEM_AM_APAC. The declaration should follow whatever form you already have there, but it's likely to be something along the lines of

public static final String SYSTEM_AM_APAC = 'System AM APAC';

where the value of the constant is the name you're using.

Variable does not exist: System AM APAC

is a compile-time error. This doesn't have anything to do with your Custom Settings as such (they are not accessed at compile time); it is exclusively about the syntax of your code.

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.