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
Praveen BonaluPraveen Bonalu 

Account Team members visual force page

Hi ,

I would like to retrive the Account team members for an account and display in the visual force page .I need to access this information from the contact record .

Can any one help me with this requirement .

Thanks
Praveen 
Mahesh DMahesh D
Hi Praveen,

Please find the below example:
 
<apex:page standardController="Account" extensions="AccountTeamMemberController">
    <apex:form >
        <apex:pageBlock title="List of Account Team Members" tabStyle="Account">
            <apex:pageBlockTable value="{!atmList}" var="atm">
                <apex:column value="{!atm.User.Name}"/>
                <apex:column value="{!atm.TeamMemberRole}"/>
                <apex:column value="{!atm.Account.Name}"/>
                <apex:column value="{!atm.AccountAccessLevel}"/>
            </apex:pageBlockTable>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class AccountTeamMemberController {

    public List<AccountTeamMember> atmList {get; set;}
    public AccountTeamMemberController(ApexPages.StandardController controller) {
        Account acc = (Account) controller.getRecord();
        
        atmList = [SELECT Id, AccountAccessLevel, AccountId, Account.Name, TeamMemberRole,UserId, User.Name FROM AccountTeamMember where AccountId =: acc.Id];
    }

}
I also tested the above code in my DE environemtn and it is working perfectly.

Please do let me know if it helps you.

Regards,
Mahesh
Praveen BonaluPraveen Bonalu
Let me share the my code with you !!!
public class MyProfilePageController {

    private User user;
    public List<AccountTeamMember> myTeam { get; set; }
    public User getUser() {
        return user;
    }

    public MyProfilePageController() {
         myTeam = [SELECT Id, AccountAccessLevel, AccountId, Account.Name, TeamMemberRole,UserId, User.Name FROM AccountTeamMember where AccountId =:user.Contact.AccountId];
        
   }
}
 
VF Page:


<apex:page  extensions="MyProfilePageController">
    <apex:form >
        <apex:pageBlockTable value="{!myTeam}" var="r">
                        <apex:column headerValue="Name">
                            <a href="/{!r.Id}">{!r.FirstName} {!r.LastName}</a>
                        </apex:column>
                        <apex:column value="{!r.Account.Name}"/>
                        <apex:column value="{!r.Account.TeamMemberRole}"/>
                        <apex:column value="{!r.User.Name}"/>

                    </apex:pageBlockTable>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

I am not using the standard controller as account
Praveen BonaluPraveen Bonalu
I am sorry I have put one more coloum  extra please ignore.

<apex:column headerValue="Name"> <a href="/{!r.Id}">{!r.FirstName} {!r.LastName}</a> </apex:column>
Mahesh DMahesh D
Hi Praveen,

What is the issue here?

Regards,
Mahesh
Praveen BonaluPraveen Bonalu
I would like to access the account team from contacts I need this vf on contact
Mahesh DMahesh D
Hi Praveen,

Please look into the code:
 
<apex:page standardController="Contact" extensions="MyProfilePageController">
    <apex:form >
        <apex:pageBlock>
            <apex:pageBlockTable value="{!myTeam}" var="r">
                <apex:column headerValue="Name">
                    <a href="/{!r.Id}">{!r.User.FirstName} {!r.User.LastName}</a>
                </apex:column>
                <apex:column value="{!r.Account.Name}"/>
                <apex:column value="{!r.TeamMemberRole}"/>
                <apex:column value="{!r.User.Name}"/>
    
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class MyProfilePageController {

    public List<AccountTeamMember> myTeam { get; set; }
    public Contact con {get; set;}
    
    public MyProfilePageController(ApexPages.StandardController controller) {
        Contact con = (Contact) controller.getRecord();
        User u = [Select Id, Contact.AccountId, Name from User where Id =: UserInfo.getUserId()];
        System.debug('================u:'+u);
        myTeam = [SELECT Id, AccountAccessLevel, AccountId, Account.Name, TeamMemberRole,UserId, User.FirstName, User.LastName, User.Name FROM AccountTeamMember where AccountId =:u.Contact.AccountId];
    }
}

Please do let me know if it helps you.

Regards,
Mahesh

 
Praveen BonaluPraveen Bonalu
Hi Mahesh ,

Please see the following code That i did in my org 

How would I Query the AccountTeamMembers from the Contact Object

VF Page :
 
<apex:page controller="MyProfilePageController">  
    <apex:form id="theForm"> 
           <apex:pageBlock title="{!$Label.site.my_profile}">
            <apex:pageBlockSection columns="1" title="My Team">
                <apex:pageBlockTable value="{!myTeam}" var="r">
                    <apex:column value="{!r.Account.Name}"/>
                    <apex:column value="{!r.Phone}"/>
                    <apex:column value="{!r.Email}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
           </apex:pageBlock>
     </apex:form>

Controller:
 
public class MyProfilePageController {

    private User user;
    public List<Contact> myTeam { get; set; }

    public User getUser() {
        return user;
    }

    public MyProfilePageController() {
        user = [SELECT id, email, username, usertype,firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax,
                WHERE id = :UserInfo.getUserId()];
       myTeam = [Select Id, Account.Name, FirstName, LastName, Title, Phone, Email from Contact where AccountId=:user.Contact.AccountId  ORDER BY Name ASC];


    }

    }

 
Mahesh DMahesh D
Hi Praveen,

Please try the below code:

 
<apex:page standardController="Contact" controller="MyProfilePageController">  
    <apex:form id="theForm"> 
           <apex:pageBlock title="{!$Label.site.my_profile}">
            <apex:pageBlockSection columns="1" title="My Team">
                <apex:pageBlockTable value="{!myTeam}" var="r">
                    <apex:column value="{!r.Account.Name}"/>
                    <apex:column value="{!r.Phone}"/>
                    <apex:column value="{!r.Email}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
           </apex:pageBlock>
     </apex:form>
 
public class MyProfilePageController {

    private User user;
    public List<Contact> myTeam { get; set; }

    public User getUser() {
        return user;
    }

    public MyProfilePageController(ApexPages.StandardController controller) {
        user = [SELECT id, email, username, usertype,firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax,
                WHERE id = :UserInfo.getUserId()];
       myTeam = [Select Id, Account.Name, FirstName, LastName, Title, Phone, Email from Contact where AccountId=:user.Contact.AccountId  ORDER BY Name ASC];


    }

    }

Please do let me know if it helps you.

Regards,
Mahesh
Praveen BonaluPraveen Bonalu
Hi mahesh,

The controller you have written  doesn't query the AccountTeammember's from Account Teams.

Thanks
Praveen 
Mahesh DMahesh D
Hi Praveen,

Please follow below code:
 
<apex:page standardController="Contact" extensions="MyProfilePageController">
    <apex:form >
        <apex:pageBlock>
            <apex:pageBlockTable value="{!myTeam}" var="r">
                <apex:column headerValue="Name">
                    <a href="/{!r.Id}">{!r.User.FirstName} {!r.User.LastName}</a>
                </apex:column>
                <apex:column value="{!r.Account.Name}"/>
                <apex:column value="{!r.TeamMemberRole}"/>
                <apex:column value="{!r.User.Name}"/>
    
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Class:
 
public class MyProfilePageController {

    public List<AccountTeamMember> myTeam { get; set; }
    public Contact con {get; set;}
    
    public MyProfilePageController(ApexPages.StandardController controller) {
        Contact con = (Contact) controller.getRecord();
        con = [Select Id, AccountId from Contact where Id =: con.Id];
        myTeam = [SELECT Id, AccountAccessLevel, AccountId, Account.Name, TeamMemberRole,UserId, User.FirstName, User.LastName, User.Name FROM AccountTeamMember where AccountId =:con.AccountId];
    }
}

Also tested the above VF page by passing the Contact Id and below is the result:

User-added image


Please do let me know if it helps you.

Regards,
Mahesh
Praveen BonaluPraveen Bonalu
I have written the code to access the AccountTeamMember Object for the customer Portal.I have found that customer portal users cannot access the "AccountTeamMember" object in salesforce 

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_accountteammember.htm