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

render a part of the Account page based on the user being part of the Account team

Trying to do what the title says. Class:

public class AccountTeamChecker {
    private ApexPages.StandardController sc;
    public AccountTeamChecker(ApexPages.StandardController sc) { = sc;
    // Returns true if the user is an account team member
    public Boolean renderELEMENT{
        get {
            if (renderELEMENT== null) {
                renderELEMENT= [
                        select count()
                        from AccountTeamMember
                        where AccountId = :sc.getId()
                        and UserId = :UserInfo.getUserId()
                        and AccountAccessLevel in ('Read', 'Edit', 'All')
                        ] > 0;
            return renderELEMENT;
        private set;

VF Page:

<apex:page standardController="Account" extensions="AccountTeamChecker" rendered="!renderELEMENT">
  <apex:pageBlock title="Rendering">

Do not even get any queries rows on my debug logs. What's not firing? thanks!
Try this

<apex:page standardController="Account" extensions="AccountTeamChecker" rendered="{!renderELEMENT}">
Thanks! It queried this time.
Hmm. Debug logs show select coutn returning 0 even though I am on the AccountTeam.
If I comment out this line:
and AccountAccessLevel in ('Read', 'Edit', 'All')
It renders properly.
 What other access could I have? I see ALL when I do a query for the Account share table. Is it b/c I am system admin?