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
rteina1.3911642333195632E12rteina1.3911642333195632E12 

How to check if Account Teams is enabled?

If the Account Teams is not enabled, the object AccountTeamMember does not exists and I have a compile error. 
I would like to know to check if the Account Teams is enabled before doing any query. 

Regards
Karan Khanna 6Karan Khanna 6
Hi,

If you want to check it through UI then follow this:

Customize | Accounts | Account Teams


If you want to check it in your code then query 'AccountTeamMember', if you find any record then it is enabled (Assuming if it is enabled then atleast one person is using it).
rteina1.3911642333195632E12rteina1.3911642333195632E12
Thanks for your reply but I can't query the object AccountTeamMember is the Account Teams is not enabled. 
When I try the following code
boolean hasAccTeamMember = false;
try {
   List<AccountTeamMember> accTeamMember =  [Select a.UserId, a.TeamMemberRole, a.IsDeleted, a.Id, a.CreatedDate, a.CreatedById, a.AccountId, a.AccountAccessLevel From AccountTeamMember a];
   System.debug(accTeamMember);
   hasAccTeamMember = true;
} catch (Exception e) {
   system.debug('error: '  + e);
}
I obtain the following error
Compile error at line 3 column 42
sObject type 'AccountTeamMember' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.
because the object AccountTeamMember doesn't exists.

It's why I wonder if there is a property somewhere in the SFDC model that indicates if the AccountTeam is enabled.

rteina1.3911642333195632E12rteina1.3911642333195632E12
EDIT:
I change the code by replacing the line
List<AccountTeamMember> accTeamMember =  [Select a.UserId, a.TeamMemberRole, a.IsDeleted, a.Id, a.CreatedDate, a.CreatedById, a.AccountId, a.AccountAccessLevel From AccountTeamMember a];
by 
List<Object> accTeamMember =  Database.query('select a.UserId, a.TeamMemberRole, a.IsDeleted, a.Id, a.CreatedDate, a.CreatedById, a.AccountId, a.AccountAccessLevel From AccountTeamMember a');
Doing this, I don't have any compilation errors.

Thanks again to have spent time to give me an answer.

Mikola SenykMikola Senyk
You can use the following describe call to check if AccountTeamMember is present:
Schema.SObjectType targetType = Schema.getGlobalDescribe().get('AccountTeamMember');
If targetType equals to null - there is no AccountTeamMember sObject and AccountTeam isn't enabled.
Karan Khanna 6Karan Khanna 6
I am glad it worked for you, please mark the appropriate answer as Best to close the thread.