• Sealless2
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

I have replaced the standard layout (View detail) for a custom object with a Visualforce page

 

<apex:page standardController="Appointment__c">
    <apex:sectionHeader title="{!$ObjectType.Appointment__c.label}" subtitle="{!Appointment__c.Name}"/>
    <apex:pageBlock title="{!$ObjectType.Appointment__c.label} Detail">
        <apex:pageBlockSection showHeader="false" columns="1">
            <apex:outputField value="{!Appointment__c.Tutor_Name__c}"/>
            <apex:outputField value="{!Appointment__c.Student_Name__c}"/>           
        </apex:pageBlockSection>
     </apex:pageBlock>    
     <apex:relatedList list="Session_Reports__r"/>
</apex:page>

 Nothing very interesting - especially since I have cut this down for demonstration purposes.  Fields from the parent object are displayed, a related list is displayed.  This works.  Until...

 

Until I attempt to view this page as a user with a profile that has no access to the child object in the related list.  This user gets the following error message instead

 

'Session_Reports__r' is not a valid child relationship name for entity Appointment 

 

If I switch back to use the default layout constructed roughly in a similar manner - two fields and the same related list - the layout is displayed properly in all cases.  Users with access to the child object see the related list, users without no access to the child object see nothing at all (including no error message!).  This is exactly the behaviour I want to replicate using a VF page.  But I can not.

 

I have tried some tips found online - remove and re-add the related list in the layout in order to make the VF work was one of them and it made no difference - but have not succeeded in making this work. It seems like I have a fundamental misunderstanding of how this should work - I really expected to be able to put in apex:relatedList and have VF figure out if it could or could not display it based on the profile of the user.  Is that not the case?

 

Thanks for any advice you can provide.

<apex:panelBar >
      <apex:repeat value="{!OpenProjects}" var="project" id="panelBarItems">
          <apex:panelBarItem label="Project Name: {!project.Project_Name__c}">
              <apex:detail subject="{!project.ID}" relatedList="false" inlineEdit="true" title="false" rendered="{!showDetails}"/>
              <apex:panelBar >
                  <apex:repeat value="{!Milestones(project.ID)}" var="milestone">
                      <apex:panelBarItem label="Milestone Name: {!milestone.Name}">
                      </apex:panelBarItem>
                  </apex:repeat>
              </apex:panelBar>
          </apex:panelBarItem>
      </apex:repeat>
  </apex:panelBar>

 

    //Get Milestones Based On Project
    public List<Milestone__c> getMilestones(ID Project) {
        return [SELECT Name FROM Milestone__c WHERE Project__c = :Project];
    }

 I'm trying to call a method "getMilestones" with a parameter called "Project" however i'm getting an apex error: Unknown Function Milestones